繁体   English   中英

@GeoPointField Elasticsearch 映射错误

[英]Bad mapping with @GeoPointField Elasticsearch

我将 spring-boot 1.5.1 与 Elasticsearch 2.3.5(用于 Mahout Recommender 系统)一起使用,所以我在映射时遇到了问题:

@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
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM