Preventing a Gauss decay function from returning 0 inside a function score query


#1

Hello,

I'm using a Gauss decay function to decrease relevance of old documents in my index (origin is current time). Is there a way to prevent a Gauss decay function from returning 0 for very old documents in this case?

I am using a function score query with both score mode and boost mode 'multiply'. For very old documents in my index, the score is always 0 because of multiplication with 0 from the Gauss Decay function (since current time is the origin and the date field of the document is so long ago). Is there a way to prevent this?

I could use boost_mode 'avg' instead of the default 'multiply', but my function score query is quite big and other functions in it make a lot more sense with multiplication. Is there a way to specify boost_mode for only one function inside a function score query?

I would not mind the Gauss decay returning something exceptionally small as long as it is not 0. Currently there is no way to distinguish between the relevance of a 3 year old document and a 5 year old document since they are both multiplied by 0 and thus end up with a score of 0. I could also mention that the function parameters (offset, scale etc.) are all customizable by an administrator other than me as a developer. Thus it would be nice to have a system in which the administrator could not "break" the query (as in specifying a minimum score that the Gauss function can return regardless of its parameters somehow).

Thanks for your time, I appreciate any feedback :slight_smile:


(Mayya Sharipova) #2

The best strategy for you is to adjust scale and decay values. For example, to distinguish between 3 year and 5 year old, increase your scale to something bigger, e.g : "scale": "365d".

If it is not possible for you to adjust scale and decay, consider adding an arbitrary small value to your gaussian score, by introducing another function with "score_mode" : "sum". Something like this: Function_score, gaussian decay, handling multiple by zero


#3

Hi Mayya,

Thanks a lot for your response. I will definitely try your second suggested option, it sounds exactly like what I am looking for. Cheers.


(system) #4

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