I'd like to write a custom Elastic Search scorer that takes all terms from the document in index, all terms from the query and based on some custom logic calculates the score.
After some research, it seems that the most straight-forward way to implement a custom scorer in Elastic Search in Java is to use its "native scripting" functionality (i.e. implementing AbstractDoubleSearchScript). The problem I have is that I can't find a way to access the original query object in such a script. I can only access the matching document and its fields. Is there some way to get access to the query object that was used for the search?
Alternatively, what is the best way to run custom Java code per result and score the match using my own (complex) algorithm that needs to know the complete term list for both the query and the document?