Overview - Function score query
What is it?
A function score query in Elasticsearch lets you change the score of documents returned by a search. Instead of just matching documents by keywords, it allows you to add custom calculations to boost or reduce scores based on numeric functions or conditions. This helps you control the order of results more precisely.
Why it matters
Without function score queries, search results are ranked only by how well they match the text. But sometimes you want to promote newer items, popular products, or documents with special attributes. Function score queries solve this by letting you combine relevance with custom scoring rules, making search results more useful and tailored.
Where it fits
Before learning function score queries, you should understand basic Elasticsearch queries and how scoring works. After mastering function score queries, you can explore advanced ranking techniques like script scoring, decay functions, and combining multiple scoring strategies.