Range query with score boosting

By default, the range query assigns a score of 1 to each matching document. What if you are using a range query in conjunction with some other query and you want to assign a higher score to the resulting document if it satisfies some criteria? We will look at compound queries such as the bool query, where you can combine multiple types of queries. The range query allows you to provide a boost parameter to enhance its score relative to other query/queries that it is combined with:

GET /amazon_products/_search
{
"from": 0,
"size": 10,
"query": {
"range": {
"price": {
"gte": 10,
"lte": 20,
"boost": 2.2
}
}
}
}

All documents that pass the filter will have a score of 2.2 instead of 1 in this query.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset