--in short -----
i want to reflect category mathcing every time it matches document's category field and it is list
Hello!
I'm in the process of implementing a search functionality using Elasticsearch's function score feature. My goal is to have the search results sorted based on a combination of factors: the BM25 score of the query, the number of views, and the degree of match with preferred categories.
Incorporating the number of views into the BM25 score is relatively straightforward, as shown below:
"functions": [
{
"script_score": {
"script": {
"source": "doNormalize(_score + doc['views'].value)"
}
}
}
],
"boost_mode": "replace"
(Note: I intend to use normalized values for the actual implementation.)
The challenge arises when trying to account for category matches. Specifically, I need to add weight each time a category in the search query matches a category in the document's category field, which is expected to be a list or set.
Considering the query will include up to 3 categories in a set, crafting a script to handle this dynamic matching is proving to be quite difficult.
I'm reaching out for any advice, insights, or examples on how to effectively script this part of the function score query.
I need your help.
Wishing everyone a great day.