I've been beating myself over how to factor both the location and the price into the scoring process. The idea is to display objects that are, in the first case, both close and lowly priced, and, in the second case, both close and highly priced.
At this point, I honestly have no idea. This is my latest attempt at building a query (of course it doesn't do what I need), but that's pretty much what I've been toying around with.
> { query:
> { bool:
> { must:
> [ { function_score:
> { score_mode: 'multiply',
> boost_mode: 'replace',
> query: { match_all: {} },
> functions:
> [ { script_score:
> { script: 'doc[\'price\'].value != 1 ? (_score * ((1/doc[\'price\'].value))) : 0' } }, // check if the value is absent, since it returns 1 in that case
> { gauss:
> { location:
> { origin: { lat: 50.00, lon: 6.00 },
> scale: '10m',
> offset: '0m',
> decay: 0.99999 } } },
> [length]: 2 ] } },
> [length]: 1 ],
> filter: [ { bool: {} }, [length]: 1 ] } },
> size: 30,
> from: 0,
> _source: [ 'id', '_score', 'location', [length]: 3 ],
> script_fields:
> { distance:
> { script: 'doc["location"].arcDistance(lat,lon)',
> params: { lat: 50.00, lon: 6.00 } } } }
An indexed document looks like this:
> {
> location: {
> lat: 50.00,
> lon: 50.00
> },
> price: 550.00,
> name: 'Test',
> rating: 5.00,
> }