My lucene app (which I am converting to ElasticSearch) uses org.apache.lucene.analysis.snowball.SnowballAnalyzer as its analyzer. I like it for the stemming abilities. How can I get support for this (or another analyzer) in ElasticSearch? Thanks.
My lucene app (which I am converting to Elasticsearch) uses
org.apache.lucene.analysis.snowball.SnowballAnalyzer as its analyzer. I
like it for the stemming abilities. How can I get support for this (or
another analyzer) in Elasticsearch? Thanks.
I looked in the org.elasticsearch.index.analysis directory and could not find any analyzer privider for the SnowballAnalyzer. So, using the BrazilianAnalyzerProvider as an example, I tried to create my own, but I keep getting this
error upon startup:
"1) Could not find a suitable constructor in com.kiha.server.services.index.KihaSnowballAnalyzer. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private."
However, my class does have one constructor with an @Inject annotation. This is what I did:
I tried adding this to my elasticsearch.json:
index:
analysis:
analyzer:
standard:
type: com.mycompany.server.services.index.MyCompanySnowballAnalyzerProvider
I put com.mycompany.server.services.index.MyCompanySnowballAnalyzerProvider into a jar in the ./lib directory. The class has this constructor:
Typo: in the above message, I meant to replace "kiha" with "mycompany" throughout, but missed some places. So "Could not find a suitable constructor in com.kiha.server.services.index.KihaSnowballAnalyzer." should be read as "Could not find a suitable constructor in com.mycompany.server.services.index.MyCompanySnowballAnalyzerProvider." in order to correspond to the rest of my post. Thanks.
This should work, strange. You get an exception for
com.kiha.server.services.index.KihaSnowballAnalyzer,
while I would expect you would get the exception for
com.kiha.server.services.index.KihaSnowballAnalyzerProvider
(note the Provider at the end). Which one are you getting again?
Typo: in the above message, I meant to replace "kiha" with "mycompany"
throughout, but missed some places. So "Could not find a suitable
constructor in com.kiha.server.services.index.KihaSnowballAnalyzer." should
be read as "Could not find a suitable constructor in
com.mycompany.server.services.index.MyCompanySnowballAnalyzerProvider." in
order to correspond to the rest of my post. Thanks.
I am getting an exception from com.kiha.server.services.index.KihaSnowballAnalyzer. Although perhaps oddly named, this class IS an extension of AbstractAnalyzerProvider. It is declared as:
public class KihaSnowballAnalyzer extends AbstractAnalyzerProvider
I do not have a class named KihaSnowballAnalyzerProvider.
I am getting an exception from
com.kiha.server.services.index.KihaSnowballAnalyzer. Although perhaps
oddly
named, this class IS an extension of AbstractAnalyzerProvider. It is
declared as:
public class KihaSnowballAnalyzer extends
AbstractAnalyzerProvider
I do not have a class named KihaSnowballAnalyzerProvider.
I can't write a test case in terms of a JUnit to repro the issue, as I can't get the server to start up without error. The test is simply to start up the server and look for errors. If you wanted to repro it, all I can think of is to try to run my class and config. To repro:
Use 0.7.1 (no particular reason I'm not on latest; just that it changes often, I can try with the latest if you advise)
Add this to your elasticsearch.yml:
index:
analysis:
analyzer:
standard:
type: com.kiha.server.services.index.KihaSnowballAnalyzer
Compile this class and put it in your classpath. Note that it is modeled on the BrazilianAnalyzer I found. Note also that to get it to compile, you need lucene-snowball-3.0.0-sources.jar.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.