How to get the terms of the query text in the plugin code?

First of all, I must apologize for my poor English.:joy:

I want to write a plugin to return script score (based on Levenshtein Distance) for each hit.

e.g.
{
"query": {
"match" : {
"message" : "The 2 QUICK Brown-Foxes"
}
},
"script_fields" : {
"new_score" : {
"script" : {
"lang": "my_expert_scripts",
"source": "pure_ld",
"params": { ... }
}
}
}
}

In the plugin's java code , how can I get the terms of the query text that it has be analyzed (e.g. "quick brown fox" in the above example) ?

I have two ideas:
One is to view the terms of the query text through the analyzer api, then pass the terms to the plugin by using params. But this way led to two remote requests.
The other one, is it possible to analyze the query text directly in the plugin code by an specified analyzer?

Besides, is there any other better solution? I do much appreciated.

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