Boosting order search
While you are configuring an index or searching against an index, you can use the boost parameter to refine the search results.
Order Service helps build an index and search for all documents that match your query parameters. It also scores and sorts those documents on their relevance, based on your query parameters. You can use the boost parameter to affect this score and refine your search results. Therefore, even with the same query parameters, the search results can be refined based on the added boost parameter. Those results that score more on the relevance, based on the boost parameter, rank better in the search results.
{
"query": {
"match": [
{
"condition": "SHOULD",
"field": "OrderDate",
"from": "2020-06-03",
"to": "2021-06-06",
"boost": 2
},
{
"condition": "SHOULD",
"field": "OrderLine.PersonInfoShipTo.City",
"value": "London"
}
]
}
}
- The boost parameter is relevant only for
SHOULD
matches. At least oneSHOULD
condition should be present to show a difference in the relevance score. In an allMUST
condition case, all the queries are equally being met and score the same in relevance. - You can boost an individual field by configuring the boost parameter at the field mapping while index creation, which gets applied at the query time. You can further refine your search results by applying another query-level boost.
- Boost values are relative to the default value of
1.0
.
The query searches for all orders that have OrderLine.PersonInfoShipTo.City
as
London
and order dates within the order date range from 2020-06-03
to 2021-06-06
. As you applied the boost parameter
on OrderDate
with a value of 2
, the orders that match the date
parameter have twice the weight as those on
the OrderLine.PersonInfoShipTo.City
field, which has the
default boost of 1.0
. Hence, the orders that match
the OrderDate
score higher on relevance and rank higher on the search results.