filter
를 적용할 시 매칭되지 않는 document 는 검색이 되지 않으므로, function_score
쿼리의 functions
에서 filter
를 대신 적용{
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"filter": {
"terms": {
"topic": ["topic1", "topic2", "topic3"]
}
},
"weight": 2
}
],
"score_mode": "sum",
"boost_mode": "multiply"
}
},
"sort": [
"_score"
]
}