Closed synhershko closed 8 years ago
I think that the only work around is to create first an index and then apply _analyze API to this index.
With plugins, you can now register it as a default analyzer. Check how we did it in official analyzer plugins.
HTH
David ;-) Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 27 juil. 2014 à 17:49, Itamar Syn-Hershko notifications@github.com a écrit :
Issuing a GET on http://localhost:9200/_analyze?analyzer=myanalyzer&text=foo provides the following response:
{ error: "ElasticsearchIllegalArgumentException[failed to find analyzer [myanalyzer]]", status: 400 } However, myanalyzer is definitely present (supplied via code as plugin). Elasticsearch also picked it up correctly as I was able to reference it from a mapping and perform indexing and searches correctly.
— Reply to this email directly or view it on GitHub.
I can confirm executing this against an existing index (even without defining a default analyzer) works, also for plugin analyzers which aren't being used in this index via its mapping or _analyzer.
This is not an obvious gotcha. I suggest to either fix it so _analyze
works when executed on the cluster the same like it was executed on an index, or the very least have a comment on that in doco...
@synhershko do you register it as a global analyzer?
@clintongormley register it where? it's being picked up from a jar file I installed via a plugin, and as such I expected it to just be available...
@synhershko Well, I don't know what you are or are not doing. Why not take a look at the kuromoji analyzer plugin and copy what it does?
https://github.com/elasticsearch/elasticsearch-analysis-kuromoji
@clintongormley aye, here is the relevant difference:
https://github.com/elasticsearch/elasticsearch-analysis-kuromoji/blob/master/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysis.java https://github.com/elasticsearch/elasticsearch-analysis-kuromoji/commit/a8ad05143548fd3051d40d1b62325fcf7ac5b6bf
Question is why once it was registered with the AnalysisModule
it's not enough to be used by the Analyze API?
This is how I register the analyzers:
https://github.com/synhershko/elasticsearch-analysis-hebrew/blob/master/src/main/java/com/code972/elasticsearch/plugins/AnalysisPlugin.java#L31 https://github.com/synhershko/elasticsearch-analysis-hebrew/blob/master/src/main/java/com/code972/elasticsearch/plugins/HebrewAnalysisBinderProcessor.java#L26
Currently, it's just the way it is. We have plans for making this easier though.
I have definitely come across this issue before. From what I remember, the issue is that the code uses the analysis service to retrieve the analyzer and it in turn requires an index.
Closing in favour of #8961
Issuing a GET on
http://localhost:9200/_analyze?analyzer=myanalyzer&text=foo
provides the following response:However,
myanalyzer
is definitely present (supplied via code as plugin). Elasticsearch also picked it up correctly as I was able to reference it from a mapping and perform indexing and searches correctly.