首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >@GeoPointField弹性搜索的坏映射

@GeoPointField弹性搜索的坏映射
EN

Stack Overflow用户
提问于 2017-02-23 13:41:12
回答 1查看 674关注 0票数 1

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

代码语言:javascript
复制
@GeoPointField
private GeoPoint location;

来自包裹:

代码语言:javascript
复制
org.springframework.data.elasticsearch.core.geo;

因此,通过mapping?pretty=1,我有:

代码语言:javascript
复制
location: {
  properties: {
   lat: {
     type: "double"
   },
   lon: {
     type: "double"
   }
  }
}

但是,我希望位置字段是geo_point类型。

因此,当我试图:

代码语言:javascript
复制
CriteriaQuery query = new CriteriaQuery(new Criteria("location").within(startLocation, range));

我有:

代码语言:javascript
复制
QueryParsingException[failed to find geo_point field [location]]

有人知道解决办法吗?Thx

EN

回答 1

Stack Overflow用户

发布于 2017-02-23 13:55:03

问题在于你的地图。它应该是geo_point类型。例如:

你可以用卷曲式来做

代码语言:javascript
复制
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"}            
    }
  }
}
'

保存数据时,可以:

代码语言:javascript
复制
"location":{
    "lat":11.68036,
    "lon":-93.3103
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42417417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档