Fields are weighted against one another where as boosting is based on a given value within a field.
Weights:
Each field has a possible weight of 0 to 10, 10 being the most substantial weight.
For Eg: If we want people to find the page they are looking for based on the query giving more importance to title, so we need to prioritize the title field. We can increase its weight so that it is more impactful than the other fields. If title had higher weight, people would find the document where this page is present in title at the top.
{
"search_fields":{
"title": {
"weight": 10
},
"subtitle": {
"weight": 5
},
"description": {
"weight": 2
}
},
"query": "Elastic"
}
Here we are requesting elastic only to return 3 field i.e title, subtitle, description with the corresponding weights as 10,5,2.
Boosts:
Weights are applied to fields. Boosts are set-up on top of fields, but they are applied to field values.
When boosting on number, date, or geolocation fields, you will need to define a function parameter and a factor. There are four types of function, depending on the boost: linear, exponential, gaussian, and logarithmic. The function and factor are used to compute half of the boosted relevance score, known as the boost value. The other half is the original document score.
They combine to produce the overall document score, which governs the order of the result set
{
"query": "Elastic",
"boosts": {
"is_elastic_query": [
{
"type": "value",
"value": "true",
"operation": "multiply",
"factor": 10
}
]
}
}
Here we are assuming that is_elastic_query is a field with value either true of false. And we are boost it using value boost by factor 10 if the value is true.
For details and examples on this please find the below link:
https://www.elastic.co/guide/en/app-search/current/relevance-tuning-guide.html