2021-08-30

A custom similarity function in elasticsearch

I want to make a custom "similarity". Actually, I just want to improve the default Okapi BM25 from ES doc. I want to add one more condition to Okami BM25's logic. This condition equals if count the number of occurrences of the searched_word in the doc > 3 return 0.0 else OkamiBM25() in pseudocode it looks like: score(D, Q)=0 if the count of the searched_word > 3 in the doc.

In my understanding, I have to make a custom "similarity" following the official ES doc recommendations and after it implements the formula of Okapi BM25 Wiki. As I understand I can describe it as the Okapi BM25 formula from Wiki above and in the return statement return=0 if searched_word > 3. But I'm wondering is it possible to wrap the default implementation of Okapi BM25 into my custom "similarity" function and then make a condition something like that return doc.freq > 3 ? 0.0 : OkapiBm25(); Unfortunately, I was not able to find such an example



from Recent Questions - Stack Overflow https://ift.tt/3Ds33J8
https://ift.tt/eA8V8J

No comments:

Post a Comment