【发布时间】:2018-08-07 15:07:01
【问题描述】:
我有如下映射:
{
"my_locations": {
"aliases": {
},
"mappings": {
"_doc": {
"properties": {
"location": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
我知道如果位置的字段类型是“geo_point”,那么我可以使用以下地理距离查询。
GET /my_locations/_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "200km",
"location" : {
"lat" : 40,
"lon" : -70
}
}
}
}
}
}
我读到我无法将位置的字段类型从文本更改为 geo_point(来自弹性搜索文档和 stackoverflow),并且我已经有很多数据。那么如何找到输入位置在一定范围内的位置呢?
【问题讨论】:
-
您需要重新索引您的数据才能将您的位置字段的类型更改为
geo_point -
@Val 但重新索引需要删除我的所有数据?
-
不,您只需创建另一个具有正确数据类型的索引,然后 reindex 会将您当前的索引复制到新索引中。然后,您将能够在新索引上运行查询。 elastic.co/guide/en/elasticsearch/reference/current/…
标签: elasticsearch