When searching for a term "xpto no blabla bla" I need to return all items that have "xpto no blablabla" and then, in order of relevance "xpto" "blablabla"
Does anyone have a light?
Thank you
When searching for a term "xpto no blabla bla" I need to return all items that have "xpto no blablabla" and then, in order of relevance "xpto" "blablabla"
Does anyone have a light?
Thank you
I was able to evolve a bit using minimum_should_match:
GET _search
{
"query": {
"match": {
"nome": {
"query": "caixa som",
"minimum_should_match": "95%"
}
}
},
"size": 15,
"from": 15
}
but I can not search for more than one field
My idea was: give priority to those who attend "sound box" then come in those that have more relevance: "box" and "sound"
To filter by more than one field we use Combining Queries with the multi_match clause that allows us to search for the searched term in more than one field.
"fields":["nome","sobrenome"]
The priority issue is related to the search term in relation to the occurrences in which they appear in the indexed documents. To return the expected result it will be necessary to mount a compound query.
{
"size": "15",
"query":{
"bool":{
"should":[
{
"multi_match":{
"query":"caixa som",
"fields":[
"nome"
],
"type":"phrase",
"minimum_should_match": "95%"
}
},
{
"multi_match":{
"query":"caixa som",
"fields":[
"nome"
]
}
}
]
}
}
}
As a result, the query places the documents that contain the terms "box sound" according to their order and proximity, this is possible because of the phrase / em>, followed by documents that contain "box" or "sound".