I am using query_string for searching my data. and wanted to sort my data such that exact match should be on top and less matched words would follow exact match.
For Instance,
{
"size": 100,
//"explain":true,
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "*increased blood glucose levels* OR *increased* OR *blood* OR *glucose* OR *levels*",
"fields": ["search_key^1", "dis_name^2", "dis_info.description^1"]
}
},
{
"query_string": {
"query": "\"increased blood glucose levels\"",
"fields": ["search_key.keyword^2", "dis_name.keyword^5", "dis_info.description.keyword^2"],
"boost":100
}
},
{
"query_string": {
"query": "\"increased blood\" OR \"increased glucose\" OR \"increased levels\" OR \"blood glucose\" OR \"blood levels\" OR \"glucose levels\" OR \"increased blood glucose\" OR \"increased blood levels\" OR \"increased glucose levels\" OR \"blood glucose levels\"",
"fields": ["search_key.keyword^2", "dis_name.keyword^5", "dis_info.description.keyword^2"],
"boost":50
}
}
]
}
}
}
As you can see, I boosted exact match query, But for semi phrase I finding all the combinations and boosting it. Problem is if i have many words than combinations can increase exponentially.
Is there any other solution for the same?