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:
(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.
Maybe I may have misunderstood, but you want your doc to score better if the category exists in your category list field. If you use the score function, wouldn't using the filter give you the result you want?
I understand, so you can have a list of categories as a parameter but these lists must have different weights in the case of a match. In this case I think the Terms set query (here you can configure how many itens in list are required for match) might make sense.
As for the weight, perhaps you need to have a logic that when creating the query creates the section of functions with each weight for the list of categories because I think it is not possible to set the weight per parameter.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.