gpt4 book ai didi

elasticsearch - Elastic Search Bool查询多个字段

转载 作者:行者123 更新时间:2023-12-03 02:29:46 24 4
gpt4 key购买 nike

我有如下的索引映射:

请求

|-> tilte 
|-> countryCode
|-> isOpen
|-> location
|-> date

我想同时制作bool和geoquery,以获取在同一国家/地区和我附近的文档以及我尝试过以下操作的 isOpen,但始终会得到一个空的hits对象。
{   "from" : 5,
"size": 5,
"query": {
"bool" : {
"must" : [
{"match" : {"countryCode": "US"}},
{"match": {"isOpen": true }}
],
"filter" : {
"geo_distance" : {
"distance" : "150km",
"location" : {
"lat" : 1111111111,
"lon" : 3333333333
}
}
}
}
},

"sort": [ { "date" : {"order" : "desc"} } ]
}

响应
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": null,
"hits": []
}
}

即使我确定有很多文档与查询匹配,但我无法得到它。有人可以帮忙吗?

最佳答案

我将从将from值从5更改为0开始。接下来,我将检查索引定义-您确定可以以使用方式搜索每个字段吗?您可以显示精确的索引定义(映射)并显示Elastic的样本项目吗?

关于elasticsearch - Elastic Search Bool查询多个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60266941/

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