elasticsearch GeoPoint location reason=failed to find mapper for [location] for geo distance based sort
Caused by: org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=illegal_argument_exception, reason=failed to find mapper for [location] for geo distance based sort] at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:496) at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:407) at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:437) ... 127 common frames omitted
spring-boot-starter-data 设置自动创建索引mapping 自动生成GeoPoint locations生成是不匹配的会报错 需要自己在kibana里面put
@Document(indexName = "merchantproduct",shards = 1,replicas = 1,createIndex = true) public class EsMerchantProductVO implements Serializable { /** * 主键id */ @ApiModelProperty(value = "主键id") @Id private String id; /** * 商户名称 */ @Field(analyzer = "ik_max_word",type = FieldType.Text) @ApiModelProperty(value = "商户名称") private String name; /** * 纬度纬度 */ @ApiModelProperty(value = "纬度纬度") @GeoPointField private GeoPoint location; }
自动生成
自动生成mapping { "merchantproduct": { "mappings": { "x": { "properties": { "name": { "type" : "text" }, "location": { "properties": { "lat": { "type": "float" }, "lon": { "type": "float" } } } } } } }
PUT /merchantproduct/_mapping?
{
"properties": {
"locations": {
"type": "geo_point"
}
}
}
如果有java api可以设置麻烦留言告知下
早年同窗始相知,三载瞬逝情却萌。年少不知愁滋味,犹读红豆生南国。别离方知相思苦,心田红豆根以生。