I've developed a scoring plugin that returns the cosine similarity between a field on the document and an input string. To do so I access terms frequency of the stored documents but I need to tokenize and filter also the input string with the same analyzer used for the stored documents.
On index creation I define custom analyzer with the wanted configuration of tokenizer and filter for a given field, but as far as I can see there's no way from the plugin to access the same custom analyzer defined in the mappings, so that I have to instantiate tokenizer and filter in the java code.
That's not really convenient, since different fields can have different tokenizers and filters with different setup params and I have to either hardcode the synced configuration between index mapping and java plugin, or pass to the plugin the same config for the index mapping and handle it in code.
So, is there any way to access custom analyzer defined in the mapping of indexes from a java plugin?
ES Version: 6.2.4