Boost text matches on presence of another field


(Sasha) #1

Hello, I have a few text fields in my index and an int array field. I request matches using text queries (like Simple String or Common Terms Query) with their corresponding weights, but I'd like them to be boosted (given higher score) when the int array field has certain values. I tried using nested combination of 'must' and 'should' boolean queries, and it appeared to work but I am concerned with possible increase of response time. I think it can also be done using 'function_score' and 'functions', something like this:

"query": {
"function_score": {
"query": { "query_string": { "fields": ["text1","text2"],"query": "my search terms" } },
"functions": [
{
"filter": { "match": { "int_array": 2 } },
"weight": 3
},
{
"filter": { "match": { "int_array": 5 } },
"weight": 4
}
]

Would it be faster?

Thanks.


(system) closed #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.