如何在Elasticsearch结果中返回geo_point的geohash?
例如,位置字段是纬度/经度值。如何将这个字段的geohash添加到结果中?
最佳答案
您需要在查询中添加fielddata_fields
,如下所示:
POST /index/_search
{
"query": {
"match_all": {}
},
"fielddata_fields": [
"location.geohash"
]
}
然后,您会得到类似的内容,
_source
和fielddata_fields
中的geohash{
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 1,
"_source": {
"location": "13.0009316,77.5947316"
},
"fields": {
"location.geohash": [
"t",
"td",
"tdr",
"tdr1",
"tdr1v",
"tdr1vw",
"tdr1vww",
"tdr1vwwz",
"tdr1vwwzb",
"tdr1vwwzbm"
]
}
}
]
}
}
关于elasticsearch - 如何在Elasticsearch结果中返回geo_point的geohash?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37599267/