1
votes

I have an elasticsearch Index containing some Documents, where each Document may have a field called "creationDate" which contains a date.

Now I'm querying the Index with a date, and I want to score Documents according to creationDate so I set up a gaussian decay function.

However as far as I understand it the decay functions are all symmetrical: i.e. if i have a document from 2005 one from 2007 and search for 2006 both documents will get the same score. However I'd like to be able to use different decays for Values less than the searchterm than for those that are greater.

Is there a built in way to achieve this?

1

1 Answers

0
votes

I am not sure if there is a built-in way for doing exactly what you want. But, according to this doc: https://www.elastic.co/guide/en/elasticsearch/guide/current/decay-functions.html if you can set the origin to some point before the mid-way between 2006 and 2007 and set the offset to some value less than 2007-origin, you would be able to achieve the same effect. For example: If you keep origin at March 2006, and offset as 3 months, the docs from Jan 2006 to June 2006 will be ranked the same, and docs from 2007 will be ranked more than docs from 2005. enter image description here If you want more control, you should be using scripts, as described here: https://www.elastic.co/guide/en/elasticsearch/guide/current/script-score.html

(image taken from the elastic doc itself)