gpt4 book ai didi

spring - GeoPoint 与 Spring Data ElasticSearch 给出错误 : QueryParsingException[field [location] is not a geo_point field]

转载 作者:行者123 更新时间:2023-12-02 19:42:23 25 4
gpt4 key购买 nike

我在 spring 中有如下的 elasticsearch 实体:

@Document(indexName = "cities_in", type = "cities")
public class CityDocument {

@Id
private String id;

@Field(type = FieldType.String)
private String city;

@Field(type = FieldType.Object)
@GeoPointField
private GeoPoint location;
}

但是当我看到使用curl curl -s -XGET 'http://localhost:9200/cities_in/cities/_mapping?pretty=1' 进行映射时,我得到的输出为:

  {
"cities_in" : {
"mappings" : {
"cities" : {
"properties" : {
"city" : {
"type" : "string"
},
"id" : {
"type" : "string"
},
"location" : {
"properties" : {
"geohash" : {
"type" : "string"
},
"lat" : {
"type" : "double"
},
"lon" : {
"type" : "double"
}
}
}
}
}
}
}
}

当我查询时,我收到以下错误:

{
"error" : {
"root_cause" : [ {
"type" : "query_parsing_exception",
"reason" : "No query registered for [geo_point]",
"index" : "cities_in",
"line" : 1,
"col" : 33
} ],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [ {
"shard" : 0,
"index" : "cities_in",
"node" : "4jGBH3m4SkqNnBwC196hTw",
"reason" : {
"type" : "query_parsing_exception",
"reason" : "No query registered for [geo_point]",
"index" : "cities_in",
"line" : 1,
"col" : 33
}
} ]
},
"status" : 400
}

为什么位置类型不是geo_point?如何用spring管理geopoint?

最佳答案

如果您使用 Spring,请确保您使用 spring 中的 GeoPoint

org.springframework.data.elasticsearch.core.geo.GeoPoint

关于spring - GeoPoint 与 Spring Data ElasticSearch 给出错误 : QueryParsingException[field [location] is not a geo_point field],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37897103/

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