Function_score, gaussian decay, handling multiple by zero


(Chris Hunt) #1

Hi

I have a function score using a gaussian decay. I would like the scores to never be zero after the multiplier so that when the gaussian function gets to zero, the documents still retained some relevance score.

Ideally, if we could add an arbitrary value to the gaussian value before the multiplication, this would solve my issue.

Does anyone have any consideration how to get this to work?

My interim (but not ideal) solution is to filter on the decay function to a certain radius to prevent multiply by zero and then add another function with a filter beyond that same radius and multiply by a very small value.

Thanks

Chris


(Mayya Sharipova) #2

function_score allows you to combine functions in any arbitrary way. For example, to avoid 0 scores, you can add an arbitrary value 0.001 to your gaussian values by using weight of 0.001 and score_mode of sum:

"function_score" : {
		"functions": [
			{
				"gauss": {
					"geo.coordinates": {
						"origin": { "lat": 14.18, "lon": -169.67 },
						"scale": "2km"
					}
				}
			},
			{
				"weight" : 0.001
			}
		],
		"score_mode" : "sum"
	}

Will this solve your problem?


Preventing a Gauss decay function from returning 0 inside a function score query
(Chris Hunt) #3

Hi.

Thank you for the reply and the suggestion. I think that's something I'll look at working with. I need to run some tests but I think that'll work. Thank you

Chris


(system) #4

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