Load custom analyzer defined in mapping from a plugin

Hello,

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

When you say "scoring plugin", which script interface exactly are you referring to?

Ryan, ScriptPlugin: one like this: https://github.com/elastic/elasticsearch/tree/master/plugins/examples/script-expert-scoring

Unfortunately you won't be able to access the registered analyzers from a ScriptPlugin. Sorry.

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