Geo location distance sorting by proximity boost

Hi,

we tried some kind of distance sorting by boosting the distance score impact.

pseudo code

options["boosts"] = {
location: {
type: "proximity",
function: "exponential",
center: options.facets.location.center,
factor: 10
}
};

It seems to work for distances lower than ~25km, but on higher distances the score is always 1.
Therefore boosting will have no affect. We tried all possible functions ( linear, proximity, exponential) and in addition higher factors.
Any idea, how to increase the score for distances higher than 30km?

Hi,

Are you applying the "proximity" boost to a numeric field (distance), or to geolocation? It is, unfortunately, a known issue that proximity boost does not work so great on numbers right now, because it uses a static scale for the decay function, which is good for some but not all cases.

More details are available in https://github.com/elastic/support-known-issues/issues/510.

I would say geolocation
based on this code
options["boosts"] = {
location: {
type: "proximity",
function: "exponential",
center: options.facets.location.center,
factor: 10
}
};

where options.facets.location.center is a geopoint

Hi,

My initial answer (based on the known issue above) was not full. The problem affects both geolocation and numeric fields, because for both of those, AppSearch will not allow you to provide a custom scale value. The default scale, in case of geolocation field type, is set to 1km, and currently there's no way to change it.

We are aware that the user experience with this feature is not great right now, and there probably will be improvements in the future. For right now, unfortunately, there's no good solution.

I found a workaround for this bug. You can divide all your coordinates by a factor. I did factor 1000 for locations all within switzerland (you might even need a bigger factor). Now I get good results for all those locations.
Obviously you also have to divide the center-coordinates.

@Florian_Stieger That's clever! Thank you for sharing the workaround.

Is there any way to set the score to 0 or 1 (something const) before calculating the boost? Otherwise i'll allways end up with some kind of mess, because the values get mixed up slightly.