I'm very new to elastic search, say in my document I have fields A, B, C, D, and I want to search the word "test" in all fields.
I want each field to have different weights, (ie. A has 10, B has 8, C has 5, and D has 2). How do I write a es query to perform that on the word I'm searching.
It's a classical use case. The most easy way is to use a multi-match query with boosters. In a multimatch add ^boostvalue to the field name to apply a boost on it
GET test/_search
{
"query": {
"multi_match": {
"query": "test",
"fields": ["A^10", "B^5", "C^2"]
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With