ES使用IK分词器仍然无法匹配搜索条件?
问题
使用了mappings的静态映射,设定了全地址由省市县组合而成,添加了数据以后使用ik分词器查询有湖南和天心区,为什么我搜索湖南天心区查不到,搜索湖南省天心区可以查询。
数据
PUT /address_list
{
"mappings": {
"properties": {
"province": {
"type": "text",
"copy_to": "fullAddress"
},
"city": {
"type": "text",
"copy_to": "fullAddress"
},
"county": {
"type": "text",
"copy_to": "fullAddress"
}
}
},
"settings": {
"index": {
"analysis.analyzer.default.type": "ik_max_word"
}
}
}
PUT /address_list/_bulk
{ "index": { "_id": "1"} }
{"province": "湖南省","city": "长沙市","county":"天心区"}
{ "index": { "_id": "2"} }
{"province": "湖南省","city": "长沙市","county":"芙蓉区"}
{ "index": { "_id": "3"} }
{"province": "广东省","city": "广州市","county":"白云区"}
{ "index": { "_id": "4"} }
{"province": "湖北省","city": "武汉市","county":"江夏区"}
查询
GET /address_list/_search
{
"query": {
"match": {
"fullAddress": {
"query": "湖南天心区",
"operator": "and"
}
}
}
}
1 个回答
按赞数排列
你的词库中有没有湖南 是不是只有湖南省没有湖南 或者说省他必须匹配这个字才可以看下你的具体规则