elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.9k stars 24.73k forks source link

Analyze API doesn't recognize plugin analyzers #7047

Closed synhershko closed 8 years ago

synhershko commented 10 years ago

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.

dadoonet commented 10 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.

synhershko commented 10 years ago

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...

clintongormley commented 10 years ago

@synhershko do you register it as a global analyzer?

synhershko commented 10 years ago

@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...

clintongormley commented 10 years ago

@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

synhershko commented 10 years ago

@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

clintongormley commented 10 years ago

Currently, it's just the way it is. We have plans for making this easier though.

brusic commented 10 years ago

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.

https://github.com/elasticsearch/elasticsearch/blob/dbcc4e9255435bd1c5ded6a2553449fb141f9249/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java#L137-L146

clintongormley commented 8 years ago

Closing in favour of #8961