I'm trying to develop a KL divergence similarities function for elasticsearch 5.1.1.
To do so, i created a KLDivergenceSimilarity.java which extends the LMSimilarity
see github link to KLDivergenceSimilarity.java
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 KLDivergenceSimilarity.java 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