I'm trying to filter my elasticsearch's result, it must return the results which are 80% compatible with the search text.
When I do this for just one key, the minimum_should_match
works perfect:
{
"size":30,
"from":930,
"query":{
"filtered":{
"query":{
"query_string":{
"default_field":"campo1",
"query":"portugues",
"minimum_should_match":"80%"
}
}
}
}
}
When I search using more than one key, the minimum_should_match
doesn't work right, return the results with 70% compatibility:
{
"size":30,
"from":123420,
"query":{
"filtered":{
"query":{
"query_string":{
"default_operator":"or",
"query":"portugues",
"fields":[
"campo1",
"campo2^5",
"campo3"
],
"minimum_should_match":"80%"
}
}
}
}
}
As far as I can think of, I need to set minimum_should_match
by key, but I don't know how to do the same.
If someone can help me out in doing so, will be great.
I needed to use bool
and multi_match
, this is right way:
{
"size":"30",
"from":0,
"query":{
"filtered":{
"query":{
"bool":{
"should":[
{
"multi_match":{
"query":"portugues",
"type":"cross_fields",
"fields":[
"campo1^3",
"campo2^5",
"campo3^3"
],
"minimum_should_match":"80%"
}
}
]
}
}
}
}
}
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