1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
| PUT test { "settings": { "analysis": { "analyzer": { "my_hanlp_analyzer": { "tokenizer": "my_hanlp" }, "hanlps": { "tokenizer": "hanlp" } }, "tokenizer": { "my_hanlp": { "type": "hanlp", "enable_custom_config": true, "enable_index_mode":true, "enable_stop_dictionary": true, "enable_custom_dictionary":true, "enable_traditional_chinese_mode":true, "enable_place_recognize":true, "enable_name_recognize":true }, "hanlp": { "type": "hanlp", "enable_custom_config": true, "enable_index_mode":true, "enable_name_recognize":true, "enable_traditional_chinese_mode":true } } } }, "mappings": { "properties": { "title":{ "type": "text", "analyzer": "my_hanlp_analyzer" }, "name":{ "type": "text", "analyzer": "hanlps" } } } }
DELETE test
POST test/_bulk {"index":{"_id":"001"}} {"title":"中華人民共和國國家2021ABC年發生了哪些事情","name":"聶強"} {"index":{"_id":"002"}} {"title":"中华人民共和国国家2021ABC发生了哪些事情","name":"聂強"} {"index":{"_id":"003"}} {"title":"中华人民共和国国家2021ABC年发生了哪些事情","name":"聂强"} {"index":{"_id":"004"}} {"title":"中华人民共和国国家2021abc年发生了哪些事情","name":"王安石"} {"index":{"_id":"005"}} {"title":"中华人民共和国国家2021年发生了哪些事情","name":"王先安"} {"index":{"_id":"006"}} {"title":"中华人民共和国国家2021ABC年发生了哪些事情","name":"李龢平"} {"index":{"_id":"007"}} {"title":"中华人民共龢国国家2021ABC年发生了哪些事情","name":"慽继光"}
# 繁 GET test/_search { "query": { "match": { "name":"聶強" } } }
# 简+繁 GET test/_search { "query": { "match": { "name":"聂強" } } }
# 简 GET test/_search { "query": { "match": { "name":"聂强" } } }
# 异体字“龢”+简 GET test/_search { "query": { "match": { "title":"中华人民共龢国" } } }
# 简 GET test/_search { "query": { "match": { "title":"中华人民共和国" } } }
# 简+繁 GET test/_search { "query": { "match": { "title":"中華人民共和國" } } }
# 简+异体“龢”+繁 GET test/_search { "query": { "match": { "title":"中華人民共龢國" } } }
# 多添加 简+繁+异体“龢” GET test/_search { "query": { "bool": { "must": [ { "match": { "title": "中華人民共和國" } },{ "match": { "name": "王先安" } } ] } } }
|