6.7. Tying it back together
We promised we’d show an example that used multiple functions, and we didn’t lie. The next listing shows a query for all of the get-together events, where
A particular term is weighted higher.
The reviews are taken into account.
Events with more attendees rank higher.
Events nearer to a geo point are boosted.
Seeing the example will make more sense, so take a look at the next listing. Listing 6.18. Tying all the function_score functions together
In this example, the following occurs:
- You start by matching all events in the index due to the match_all.
- You then boost events that have the term “hadoop” in their description using the weight function.
- Next, you use the number of reviews an event received to modify the score with thefield_value_factor function.
- Then you take the number of attendees into account using the script_score.
- Finally, you make the score gradually decay as it gets farther from your origin point with thegauss decay.