Correlation/updation of document score on timestamp, during query time in kibana search

Hi @Rahul_Lao,

queries executed in the filter context do not influence the score. But there are two way of using the geo distance query to influence the sorting as explained in The Definitive Guide:

Only the second solution can currently be used in Kibana's Discover app at the moment, because it is not possible to specify the _geo_distance clause in the sort array. When sorting by the _score field, the query could look similar to:

{
  "query": {
    "bool": {
      "must": {
        "function_score": {
          "${YOUR_DECAY_FUNCTION}": {
            "geo.coordinates": {
              "origin": {
                "lat": ${YOUR_LATITUDE},
                "lon": ${YOUR_LONGITUDE}
              },
              "offset": "${YOUR_OFFSET}km",
              "scale": "${YOUR_SCALE}km"
            }
          }
        }
      },
      "filter": {
        "geo_distance": {
          "distance": "${YOUR_CUTOFF_DISTANCE}km",
          "geo.coordinates": {
            "lat": ${YOUR_LATITUDE},
            "lon":${YOUR_LONGITUDE}
          }
        }
      }
    }
  }
}
1 Like