如何将距离值存储到SortValues或实体 [英] How to Store Distance value to SortValues or Entity

查看:110
本文介绍了如何将距离值存储到SortValues或实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用SDE4.0 @Query和SearchHit将距离值存储到SortValues或实体

How to Store Distance value to SortValues or Entity using SDE4.0 @Query, and SearchHit

"sort": [
  {
    "_geo_distance" : {
      "codenames.geoLocation" : [
        {
          "lat" : 32.846027,
          "lon" : -96.84987
        }
      ],
      "unit" : "mi",
      "order" : "asc",
    }
  }
]


推荐答案

您必须添加您的存储库查询的排序参数,请参见描述了Spring Data Elasticsearch 4的文档

You have to add a Sort parameter t your repository query, see the documentation for Spring Data Elasticsearch 4 where this is described.

在您的情况下,您需要:

In your case you'd need:

Sort sort = Sort.by(
    new GeoDistanceOrder("geoLocation", new GeoPoint(32.846027, -96.84987))
        .withUnit("mi")
        .with(Sort.Direction.ASC)
);

您可以省略排序方向,因为ASC是默认值

you can leave out the sort direction, because ASC is the default value

这篇关于如何将距离值存储到SortValues或实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆