diff --git a/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/SefariaAnalyzerFactory.java b/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/SefariaAnalyzerFactory.java new file mode 100644 index 0000000..20900e2 --- /dev/null +++ b/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/SefariaAnalyzerFactory.java @@ -0,0 +1,22 @@ +package org.sefaria.sefariaplugin; + +import org.apache.lucene.analysis.Analyzer; +import org.elasticsearch.plugin.analysis.AnalyzerFactory; +import org.elasticsearch.plugin.NamedComponent; +import org.elasticsearch.plugin.Inject; + +import org.sefaria.sefariaplugin.analysis.SefariaAnalyzer; + + +@NamedComponent( "sefaria-naive-lemmatizer") +public class SefariaAnalyzerFactory implements AnalyzerFactory { + + @Inject + public SefariaAnalyzerFactory() { + } + + @Override + public Analyzer create() { + return new SefariaAnalyzer(); + } +} \ No newline at end of file diff --git a/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/plugin/SefariaAnalyzerProvider.java b/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/plugin/SefariaAnalyzerProvider.java deleted file mode 100644 index 65f2ef7..0000000 --- a/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/plugin/SefariaAnalyzerProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.sefaria.sefariaplugin.plugin; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider; -import org.sefaria.sefariaplugin.analysis.SefariaAnalyzer; - -public class SefariaAnalyzerProvider extends AbstractIndexAnalyzerProvider { - private final SefariaAnalyzer analyzer; - - public SefariaAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) { - super(indexSettings, name, settings); - - analyzer = new SefariaAnalyzer(); - } - - @Override public SefariaAnalyzer get() { - return this.analyzer; - } -} diff --git a/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/plugin/SefariaPlugin.java b/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/plugin/SefariaPlugin.java deleted file mode 100644 index 2a3782e..0000000 --- a/Sefaria-ElasticSearch-naive-lemmatizer/src/main/java/org/sefaria/sefariaplugin/plugin/SefariaPlugin.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.sefaria.sefariaplugin.plugin; -import org.apache.lucene.analysis.Analyzer; -import org.elasticsearch.index.analysis.AnalyzerProvider; -import org.elasticsearch.indices.analysis.AnalysisModule; -import org.elasticsearch.plugins.AnalysisPlugin; -import org.elasticsearch.plugins.Plugin; - -import java.util.HashMap; -import java.util.Map; - -//https://amsterdam.luminis.eu/2017/01/31/creating-elasticsearch-plugin-basics/ -//http://david.pilato.fr/blog/2016/10/19/adding-a-new-rest-endpoint-to-elasticsearch-updated-for-ga/ -//https://github.com/duydo/elasticsearch-analysis-vietnamese/blob/master/src/main/java/org/elasticsearch/plugin/analysis/vi/AnalysisVietnamesePlugin.java -//https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis.html -//GOLD MINE? https://github.com/medcl/elasticsearch-analysis-ik -//GOLD MINE? https://github.com/medcl/elasticsearch-analysis-pinyin -//GOLD MINE? https://github.com/ofir123/elasticsearch-network-analysis -public class SefariaPlugin extends Plugin implements AnalysisPlugin { - - @Override - public Map>> getAnalyzers() { - Map>> extra = new HashMap<>(); - - extra.put("sefaria-naive-lemmatizer", SefariaAnalyzerProvider::new); - - return extra; - } - -}