So what I'm trying to achieve is partial matching with customized searchable fields per index.
I generate a match_phrase_prefix
with the value to search, and if it is more than one word, I generate another one per word.(I could use prefix
, but it bugged, or has undocumented settings).
In this case, I'm trying to look up for "belden cable"
; the query looks like this:
{
"query":{
"bool":{
"should":
[
{
"indices":{
"indices":["addresss"],
"query":{
"bool":{
"should":
[
{"match_phrase_prefix":{"name":"BELDEN CABLE"}}
{"match_phrase_prefix":{"name":"BELDEN"}},
{"match_phrase_prefix":{"name":"CABLE"}}
]
}
},
"no_match_query":"none"
}
},
{
"indices":{
"indices":["customers"],
"query":{
"bool":{
"should":[
{"match_phrase_prefix":{"_all":"BELDEN CABLE"}},
{"match_phrase_prefix":{"_all":"CABLE"}},
{"match_phrase_prefix":{"_all":"BELDEN"}}
]
}
},
"no_match_query":"none"
}
}
]
}
}
My target search is to get the results that have "belden cable"
first, then the searches for just "belden"
or "cable"
.
This returns(by example) 4 results that have "belden cable"
, then a result that has only "cable"
, then more results of "belden cable"
.
How can I boost the results that have the complete value of the search?("belden cable")
I've tried separating the indices query of both words and separated words, but it gives worst relevance results.
Also I've tried using a boost statement inside the match_phrase_prefix
for "belden cable"
without change in the results..