用于Elastic Search中distance_feature的Java API

sg_sn

我正在尝试使用弹性搜索distance_feature实现日期和地理位置字段的相关性提升。哪种Java API与distance_feature查询相对应?

以下查询在Kibana上运行良好:

{
  "query": {
    "bool": {
      "should": [
        {
          "multi_match": {
            "query": "mountain",
            "fields": [
              "description$string"
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "distance_feature": {
                  "field": "location$location",
                  "pivot": "1km",
                  "origin": [
                    -35.58,20.4
                  ],
                  "boost": 1
                }
              },
              {
                "distance_feature": {
                  "field": "date_established$date",
                  "pivot": "10d",
                  "origin": "now",
                  "boost": 10
                }
              }
            ]
          }
        }
      ]
    }
  },
  "_source": {
    "includes": [
      "title$string",
      "location$location",
      "date_established$date"
    ]
  }
}```

I do not want to use the decay function for this case.

您可以使用DistanceFeatureQueryBuilder该类

对于地理位置:

GeoPoint geo = new GeoPoint(-35.58, 20.4);
DistanceFeatureQueryBuilder.Origin origin = new DistanceFeatureQueryBuilder.Origin(geo);
DistanceFeatureQueryBuilder dfqb = new DistanceFeatureQueryBuilder("location$location", origin, "1km")

对于日期:

Origin origin = new Origin("now");
DistanceFeatureQueryBuilder dfqb = new DistanceFeatureQueryBuilder("date_established$date", origin, "10d")

我已经提交了问题,要求增加一个工厂方法distance_featureQueryBuilders

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章