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" } } } } } } } kibana 自己put进去的 { "merchantproduct": { "mappings": { "x": { "properties": { "name": { "type" : "text" }, "location": { "type":"geo_point" } } } } }
如果有java api可以设置麻烦留言告知下