如何在Elasticsearch结果中返回geo_point的geohash?
例如,位置字段是lat / lon值。如何在结果中添加此字段的geohash?
答案 0 :(得分:1)
您需要在查询中添加fielddata_fields
,如下所示:
POST /index/_search
{
"query": {
"match_all": {}
},
"fielddata_fields": [
"location.geohash"
]
}
你会得到这样的东西,_source
和fielddata_fields
中的地理位置
{
"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"
]
}
}
]
}
}