commit 121d0b61acbab642029ed08f94e2d7c00dbbf762 Author: Shay Banon Date: Thu Jan 19 15:57:42 2012 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..06a1e6fedb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/data +/work +/logs +/.idea +/target +.DS_Store +*.iml diff --git a/README.md b/README.md new file mode 100644 index 00000000000..6d18e14dda0 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +Stempel (Polish) Analysis for ElasticSearch +================================== + +The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. + +In order to install the plugin, simply run: `bin/plugin -install elasticsearch/elasticsearch-analysis-stempel/1.0.0`. + + -------------------------------------------------- + | Stempel Analysis Plugin | ElasticSearch | + -------------------------------------------------- + | master | 0.18 -> master | + -------------------------------------------------- + | 1.0.0 | 0.18 -> master | + -------------------------------------------------- + +The plugin includes the `polish` analyzer. diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000000..b4b52e8a6f8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,137 @@ + + + elasticsearch-analysis-stempel + 4.0.0 + org.elasticsearch + elasticsearch-analysis-stempel + 1.0.0-SNAPSHOT + jar + Stempel (Polish) Analysis for ElasticSearch + 2009 + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + scm:git:git@github.com:elasticsearch/elasticsearch-analysis-stempel.git + scm:git:git@github.com:elasticsearch/elasticsearch-analysis-stempel.git + + http://github.com/elasticsearch/elasticsearch-analysis-stempel + + + + org.sonatype.oss + oss-parent + 7 + + + + 0.18.5 + + + + + + + + org.elasticsearch + elasticsearch + ${elasticsearch.version} + compile + + + + org.apache.lucene + lucene-stempel + 3.5.0 + compile + + + + log4j + log4j + 1.2.16 + runtime + + + + org.testng + testng + 6.3.1 + test + + + + org.hamcrest + hamcrest-core + 1.3.RC2 + test + + + + org.hamcrest + hamcrest-library + 1.3.RC2 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.11 + + + **/*Tests.java + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + + jar + + + + + + maven-assembly-plugin + + ${project.build.directory}/releases/ + + ${basedir}/src/main/assemblies/plugin.xml + + + + + package + + single + + + + + + + \ No newline at end of file diff --git a/src/main/assemblies/plugin.xml b/src/main/assemblies/plugin.xml new file mode 100644 index 00000000000..4e7ee42c376 --- /dev/null +++ b/src/main/assemblies/plugin.xml @@ -0,0 +1,26 @@ + + + + + zip + + false + + + / + true + true + + org.elasticsearch:elasticsearch + + + + / + true + true + + org.apache.lucene:lucene-stempel + + + + \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalysisBinderProcessor.java b/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalysisBinderProcessor.java new file mode 100644 index 00000000000..0d3495c8e13 --- /dev/null +++ b/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalysisBinderProcessor.java @@ -0,0 +1,32 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.index.analysis.pl; + +import org.elasticsearch.index.analysis.AnalysisModule; + +/** + */ +public class PolishAnalysisBinderProcessor extends AnalysisModule.AnalysisBinderProcessor { + + @Override + public void processAnalyzers(AnalyzersBindings analyzersBindings) { + analyzersBindings.processAnalyzer("polish", PolishAnalyzerProvider.class); + } +} diff --git a/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalyzerProvider.java new file mode 100644 index 00000000000..ad583f9bc8f --- /dev/null +++ b/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalyzerProvider.java @@ -0,0 +1,52 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.index.analysis.pl; + +import org.apache.lucene.analysis.pl.PolishAnalyzer; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.assistedinject.Assisted; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.Index; +import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider; +import org.elasticsearch.index.analysis.Analysis; +import org.elasticsearch.index.settings.IndexSettings; + +import java.util.Set; + +/** + */ +public class PolishAnalyzerProvider extends AbstractIndexAnalyzerProvider { + + private final PolishAnalyzer analyzer; + + @Inject + public PolishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + super(index, indexSettings, name, settings); + Set stopWords = Analysis.parseStopWords(env, settings, PolishAnalyzer.getDefaultStopSet(), version); + + analyzer = new PolishAnalyzer(version, stopWords); + } + + @Override + public PolishAnalyzer get() { + return this.analyzer; + } +} diff --git a/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysis.java b/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysis.java new file mode 100644 index 00000000000..c2f6db774f8 --- /dev/null +++ b/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysis.java @@ -0,0 +1,42 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.indices.analysis.pl; + +import org.apache.lucene.analysis.pl.PolishAnalyzer; +import org.elasticsearch.common.component.AbstractComponent; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.analysis.AnalyzerScope; +import org.elasticsearch.index.analysis.PreBuiltAnalyzerProviderFactory; +import org.elasticsearch.indices.analysis.IndicesAnalysisService; + +/** + * Registers indices level analysis components so, if not explicitly configured, will be shared + * among all indices. + */ +public class PolishIndicesAnalysis extends AbstractComponent { + + @Inject + public PolishIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { + super(settings); + indicesAnalysisService.analyzerProviderFactories().put("default", new PreBuiltAnalyzerProviderFactory("default", AnalyzerScope.INDICES, new PolishAnalyzer(Lucene.ANALYZER_VERSION))); + } +} diff --git a/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysisModule.java b/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysisModule.java new file mode 100644 index 00000000000..7a23a1709e6 --- /dev/null +++ b/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysisModule.java @@ -0,0 +1,32 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.indices.analysis.pl; + +import org.elasticsearch.common.inject.AbstractModule; + +/** + */ +public class PolishIndicesAnalysisModule extends AbstractModule { + + @Override + protected void configure() { + bind(PolishIndicesAnalysis.class).asEagerSingleton(); + } +} diff --git a/src/main/java/org/elasticsearch/plugin/analysis/stempel/AnalysisStempelPlugin.java b/src/main/java/org/elasticsearch/plugin/analysis/stempel/AnalysisStempelPlugin.java new file mode 100644 index 00000000000..0eacabd104a --- /dev/null +++ b/src/main/java/org/elasticsearch/plugin/analysis/stempel/AnalysisStempelPlugin.java @@ -0,0 +1,58 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.plugin.analysis.stempel; + +import org.elasticsearch.common.collect.ImmutableList; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.index.analysis.pl.PolishAnalysisBinderProcessor; +import org.elasticsearch.indices.analysis.pl.PolishIndicesAnalysisModule; +import org.elasticsearch.plugins.AbstractPlugin; + +import java.util.Collection; + +/** + * + */ +public class AnalysisStempelPlugin extends AbstractPlugin { + + @Override + public String name() { + return "analysis-stempel"; + } + + @Override + public String description() { + return "Stempel (Polish) analysis support"; + } + + @Override + public Collection> modules() { + return ImmutableList.>of(PolishIndicesAnalysisModule.class); + } + + @Override + public void processModule(Module module) { + if (module instanceof AnalysisModule) { + AnalysisModule analysisModule = (AnalysisModule) module; + analysisModule.addProcessor(new PolishAnalysisBinderProcessor()); + } + } +} diff --git a/src/main/resources/es-plugin.properties b/src/main/resources/es-plugin.properties new file mode 100644 index 00000000000..23e28d4c3b0 --- /dev/null +++ b/src/main/resources/es-plugin.properties @@ -0,0 +1 @@ +plugin=org.elasticsearch.plugin.analysis.stempel.AnalysisStempelPlugin