gpt4 book ai didi

elasticsearch - 使用 geo_distance 过滤器不会返回任何使用 ElasticSearch 的命中

转载 作者:行者123 更新时间:2023-12-03 01:53:27 24 4
gpt4 key购买 nike

我无法让我的过滤器查询与 geo_distance 一起正常工作。它似乎返回 0 次点击。但是,如果我不尝试查找地理位置,我的所有其他查询都有效。

我正在使用 2.3.1 版的 ElasticSearch

{
"name" : "Mar-Vell",
"cluster_name" : "elastic-logs",
"version" : {
"number" : "2.3.1",
"build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
"build_timestamp" : "2016-04-04T12:25:05Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}

我通过使用 json 发出请求,将我的位置键映射为“geo_point”类型,如下所示:
curl -XPUT 'http://10.0.7.181:9200/connections/profile/_mapping' -d '
{

"profile" : {
"properties" : {
"location" : {
"type" : "geo_point"
}
}
}
}

它返回这个。我假设我的更改已生效。
{"acknowledged":true}

这是我的数据示例
  {
"_index": "connections",
"_type": "profile",
"_id": "92",
"_score": 1,
"_source": {
"profile": {
"location": {
"lon": -111.8909815,
"lat": 40.7607818
},
"age": 44,
"school": {
"undergraduate": {
"universityId": 1814,
"active": true,
"programId": 9
},
"graduate": {
"universityId": 1814,
"active": true,
"programId": 7
}
},
"bio": "Everything is awesome! 👽"
},
"id": 0,
"active": false,
"optIn": true
}
}

我发送到我们的 ElasticSearch 的查询。没什么疯狂的。
{
"filter" : {
"geo_distance" : {
"distance" : "1000mi",
"distance_type": "plane",
"location" : {
"lon": -111.8391029,
"lat": 40.7607818
}
}
},
"query" : {
"match_all" : {}
}
}

我尝试将距离更改为 1 英里、100 英里和 1000 英里。它应该返回 100 英里但没有显示的东西。我也尝试过使用不同的单位测量来看看它是否会做任何事情。同样的交易。

坐标位于盐湖城。并且经纬度的顺序应该是对的。我不确定我还应该尝试什么。

最佳答案

您的位置字段的名称是 location ,但在您的查询中,您使用的是 geoPoint作为字段名称。试试这个:

{
"filter" : {
"geo_distance" : {
"distance" : "1000mi",
"distance_type": "plane",
"location" : {
"lon": -111.8391029,
"lat": 40.7607818
}
}
},
"query" : {
"match_all" : {}
}
}

更新 : 好的,这是我看到的明显错误,所以我没有再看下去。这是我的一个项目中的一个有效查询(带有您的值):
{
"query": {
"bool": {
"must": {
"match_all": []
},
"filter": {
"geo_distance": {
"distance": "1000mi",
"distance_type": "plane",
"location": {
"lat": "-111.8391029",
"lon": "40.7607818"
}
}
}
}
}
}

那应该行得通。

关于elasticsearch - 使用 geo_distance 过滤器不会返回任何使用 ElasticSearch 的命中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38486614/

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