【发布时间】:2016-11-24 00:08:59
【问题描述】:
我无法让我的过滤器查询与 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 英里但没有显示的东西。我也尝试过使用不同的单位测量来看看它是否会做任何事情。同样的交易。
坐标位于盐湖城。并且经纬度的顺序应该是对的。我不确定我还应该尝试什么。
【问题讨论】: