首页 文章

ElasticSearch - 位置数组的地理空间搜索

提问于
浏览
0

我正在使用Spring Data创建一个带有两种类型的餐厅和分支的索引 . 餐厅有许多分支作为嵌套类型 . 当我创建此映射时,Spring Data / ElasticSearch会自动将Branch类型中的位置字段转换为纬度,经度数组,因此无法进行地理空间查询 . 这里是:

我想在branch.location上执行搜索以进行地理空间搜索,但弹性搜索不会将位置视为地理位置,而是字符串数组,因此不可能,请建议我需要做什么或我出错的地方 .

class Restaurant {
    @Field( type = FieldType.Nested)
    private List<Branch> branches = new ArrayList<Branch>();
}

class Branch {
   private GeoPoint location;
}

1 回答

  • 0

    确保您正在使用

    org.springframework.data.elasticsearch.core.geo.GeoPoint

    并不是

    org.elasticsearch.common.geo.GeoPoint

    或者(也许更好),自己定义映射,而不是让spring / elasticsearch为您完成 .

相关问题