java - @GeoPointField Elasticsearch 的错误映射

标签 java spring elasticsearch spring-data-elasticsearch

我正在使用 spring-boot 1.5.1 和 Elasticsearch 2.3.5(用于 Mahout 推荐系统),所以我在映射方面遇到问题:

@GeoPointField
private GeoPoint location;

来自包:

org.springframework.data.elasticsearch.core.geo;

所以,通过 localhost:9200/.../.../_mapping?pretty=1我有:

location: {
  properties: {
   lat: {
     type: "double"
   },
   lon: {
     type: "double"
   }
  }
}

但是,我想要位置字段的 geo_point 类型。

结果,当我尝试时:

CriteriaQuery query = new CriteriaQuery(new Criteria("location").within(startLocation, range));

我有:

QueryParsingException[failed to find geo_point field [location]]

有人知道解决办法吗? 谢谢

最佳答案

问题出在你的映射上。它应该是 geo_point 类型。例如
您可以使用curl PUT来做到这一点

curl -XPUT 'http://localhost:9200/your_index/_mapping/your_type' -d '
{
    "your_type" : {
        "properties" : {

          "phone": {
        "type": "string", "index": "not_analyzed"
    },
    "webSite": {
        "type": "string", "index": "not_analyzed"
    }
    "location": {
        {"type":    "geo_point"}            
    }
  }
}
'

保存数据时,您可以执行以下操作:

"location":{
    "lat":11.68036,
    "lon":-93.3103
}

关于java - @GeoPointField Elasticsearch 的错误映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42417417/

相关文章:

java - 事务在使用 OpenJPA 时处于非 Activity 状态

java - Apache Ant 正在创建奇怪的目录

java - org.hibernate.HibernateException : Could not instantiate resultclass

java - 选择什么技术? Spring Batch 还是 Hadoop?

java - 如何使用 Spring 异常处理 POST REST 正确的错误状态代码

Java 8 - 如何在不创建临时变量的情况下从 List<T> 和 new T 创建 Iterable?

java - 使用 Java Spring 启动的 Redis session

elasticsearch - 分析器自动完成名称

java - 渗透器在 Elasticsearch 中的含义/作用是什么?

solr - 有没有类似Solr分析工具的Elasticsearch插件?