Custom similarty: get query length within the score function

I'm trying to develop a KL divergence similarities function for elasticsearch 5.1.1.

To do so, i created a which extends the LMSimilarity
see github link to

My question: how can I get the query length?
for example: if the user submit "heart attack" the query length that i need is 2.

I know there is a maxOverlap which contain the total number of terms in the query, but how can I access it from my score function in file?

alternatively, I saw lucene has axiomatic similarity function that accept query length as a setting parameter. If I use such approach, is there anyway that i can change the similarity setting on the fly without closing and reopening my index?

Thank you

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