I am running a following query to boost exact match over multi_match in elastic search. But, not getting the expected results.
My goal is to boost in following order: "java developer" > java AND developer > java OR developer
Can someone help in troubleshooting this? Need to know how do I give boost to match_phrase here and how to add remaining fields in match_phrase
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
]
}
}
],
"should": [
{
"match_phrase": {
"title": "java developer"
}
},
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
],
"operator": "and",
"boost": 4
}
}
]
}
}
Thanks so much for your help.
Returns documents matching a positive query while reducing the relevance score of documents that also match a negative query. You can use the boosting query to demote certain documents without excluding them from the search results.
Minimum Should Match is another search technique that allows you to conduct a more controlled search on related or co-occurring topics by specifying the number of search terms or phrases in the query that should occur within the records returned.
Match phrase queryeditA phrase query matches terms up to a configurable slop (which defaults to 0) in any order. Transposed terms have a slop of 2.
To better search text fields, the match query also analyzes your provided search term before performing a search. This means the match query can search text fields for analyzed tokens rather than an exact term. The term query does not analyze the search term. The term query only searches for the exact term you provide.
Here is what worked for me:
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
]
}
}
],
"should": [
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
],
"type": "phrase",
"boost": 10
}
},
{
"multi_match": {
"query": "java developer",
"fields": [
"title",
"content",
"tags",
"summary"
],
"operator": "and",
"boost": 4
}
}
]
}
}
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