Boost field A based on range field B

(Maarten Koopmans) #1


I have trimmed down my issue to this minimal use case. Say I have a document type fruits:

"pricePerKg": 9

What I would like to be able to do (but can't seem to figure out) is boost the flavourScore if the pricePerKg is in a a range, say 8-10/kg, but not otherwise. I'm pretty sure this is possible - the abstract question would be:

Boost field A if the value of field B falls within a numeric range.

Any help (especially a sample query DSL) or insight greatly appreciated!



(Maarten Koopmans) #2


I'd expected somebody out there would know the trick..... Is this impossible with ElasticSearch or a case of RTFM? If the latter, a pointer would be appreciated!

Warm regards,

Maarten Koopmans

(David Pilato) #3

I wonder if function score could help you here?

(Maarten Koopmans) #5

I briefly looked at that, but anything else than the pseudo-code:

if X in range (a,b) then boost Y

seems overly complicated. I can live with if it's complicated, but then I would like to use this thread to create an abstraction using the more complicated building blocks to allow those coming after me with this need to write it more like the ^^

(Maarten Koopmans) #6

I don't see how I can do this in one query.

I can see the boost on say 8-10e/kg if I combine that range as filter and a boost on the flavourFactor if the field exists (if that is possible. But I think I would need a second query to get all the results below 8e

(Maarten Koopmans) #7

Maybe I could use a script score function, I can see how I could partition the data in painless as scripting language. But I'm not sure how can I enable a boots in painless other than changing the documents score (which would be primitive, like multiplying by X).

Is there a "boost" in painless?

(system) #8

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