Java API for distance_feature in Elastic Search

I am trying to implement a relevance boost for date and geo-location fields using elastic search distance_feature. What Java API corresponds to distance_feature query?

Using decay function does not solve my use case

The following query works fine on 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"
    ]
  }
}

Take a look at the DistanceFeatureQueryBuilder class

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.