gpt4 book ai didi

elasticsearch - Elasticsearch未按预期过滤

转载 作者:行者123 更新时间:2023-12-03 01:48:00 25 4
gpt4 key购买 nike

我正在使用Elasticsearch 1.4

我有一个索引:

curl -XPUT "http://localhost:49200/customer" -d '{"mappings": {"venues": {"properties": {"party_id": {"type": "string"},"sup_party_id": {"type": "string"},"location": {"type": "geo_point"}            }       }    }}'

并放置一些数据,例如:
curl -XPOST "http://localhost:49200/customer/venues/RO2" -d '{ "party_id":"RO2",  "sup_party_id": "SUP_GT_R1A_0001","location":{ "lat":"21.030347","lon":"105.842896" }}'
curl -XPOST "http://localhost:49200/customer/venues/RO3" -d '{ "party_id":"RO3", "sup_party_id": "SUP_GT_R1A_0004","location":{ "lat":"20.9602051","lon":"105.78709179999998" }}'

而我的过滤器是:
{"constant_score":
{"filter":
{"and":
[{"terms":
{"sup_party_id":["SUP_GT_R1A_0004","SUP_GT_R1A_0001","RO2","RO3","RO4"]
}
},{"geo_bounding_box":
{"location":
{"top_left":{"lat":25.74546096707413,"lon":70.43503197075188},
"bottom_right":{"lat":6.342579199578783,"lon":168.96042259575188}
}
}
}]
}
}
}

上面的查询不返回数据,但是当我删除以下术语时会返回数据:
{"terms":
{"sup_party_id":["SUP_GT_R1A_0004","SUP_GT_R1A_0001","RO2","RO3","RO4"]
}
}

请给我看这个问题,任何建议表示赞赏!

最佳答案

这是因为sup_party_id字段是经过分析的字符串。像这样更改您的映射,它将起作用:

curl -XPUT "http://localhost:49200/customer" -d '{
"mappings": {
"venues": {
"properties": {
"party_id": {
"type": "string"
},
"sup_party_id": {
"type": "string",
"index": "not_analyzed" <--- add this
},
"location": {
"type": "geo_point"
}
}
}
}
}'

关于elasticsearch - Elasticsearch未按预期过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42387470/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com