I have the following query:
'{"query": {"query_string": {"query": "ABC"}'
this will search all fields in given index\type ex. Mytype has field1, field2, field3 this will match "ABC" to field1, field2, field3
Equal value is placed on the 3 fields I need to prioritize the field ranking so let's say the priority should be field2, field3, field1
How do I modify my search to set the field ranking/priority?
In my research I saw _score but that looks like its used to prioritize each doc instead of the fields.
Here is update for newer Elasticsearch versions. Query like this should boost results depending on respective fields content:
GET /_search
{
"query":{
"simple_query_string" : {
"query": "ABC",
"fields": [
"field2^3",
"field3^2",
"field1^1"]
}
}
}
Pay attention to "^3" after field2, this will boost results, so if "ABC" is found in all fields, they will be sorted as:
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