0
votes

Using the decay functions as described here: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-decay

GET /_search
{
    "query": {
        "function_score": {
            "gauss": {
                "date": {
                      "origin": "2013-09-17", 
                      "scale": "10d",
                      "offset": "5d", 
                      "decay" : 0.5 
                }
            }
        }
    }
}

Is it possible set a maximum decay? Basically, even if the item was 1 year old it would still only decay by 0.25.

1
would you be able to use a function score with a filter and have two of those one with 0.25 (max decay) to kick in for item older than certain date and 0.5 for items newer than certain date ? - keety
Good suggestion, I didn't know filters could be applied like that! - skalb

1 Answers

2
votes

You can use something like this:

GET /_search
{
  "query": {
    "function_score": {
      "functions": [
        {
          "gauss": {
            "date": {
              "origin": "2013-09-17", 
              "scale": "10d",
              "offset": "5d",
              "decay": 0.5
            }
          }
        }, 
        {
          "weight": 0.25
        }
      ], 
      "score_mode": "max"
    }
  }
}