• 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"
                  }
                }
              }
            }
          }
        }
      }
    
    kibana 自己put进去的
    {
      "merchantproduct": {
        "mappings": {
          "x": {
            "properties": {
              "name": {
               "type" : "text"
              },
              "location": {
                "type":"geo_point"
              }
            }
          }
        }
      }

    如果有java api可以设置麻烦留言告知下

  • 相关阅读:
    vue的class绑定
    less里面calc() 语法
    问题
    Spring Boot面试题
    Redis面试题
    nginx面试题
    rabbitMQ面试题
    Linux+Git命令
    docker
    JAVA常用单词
  • 原文地址:https://www.cnblogs.com/shanheyongmu/p/16363076.html
Copyright © 2020-2023  润新知