Skip to content

Commit 3401c21

Browse files
committed
Can not upgrade kuromoji plugin from elasticsearch 0.90.5
Due to fix [3790](elastic/elasticsearch#3790) in core, upgrading an analyzer provided as a plugin now fails. See elastic/elasticsearch#5030 for details. Issue is in elasticsearch core code but can be fixed in plugins by overloading `PreBuiltAnalyzerProviderFactory`, `PreBuiltTokenFilterFactoryFactory`, `PreBuiltTokenizerFactoryFactory` or `PreBuiltCharFilterFactoryFactory ` when used. Closes #21
1 parent a3246a2 commit 3401c21

File tree

4 files changed

+120
-6
lines changed

4 files changed

+120
-6
lines changed

src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysis.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public KuromojiIndicesAnalysis(Settings settings,
4343
super(settings);
4444

4545
indicesAnalysisService.charFilterFactories().put("kuromoji_iteration_mark",
46-
new PreBuiltCharFilterFactoryFactory(new CharFilterFactory() {
46+
new KurumojiCharFilterFactoryFactory(new CharFilterFactory() {
4747
@Override
4848
public String name() {
4949
return "kuromoji_iteration_mark";
@@ -58,7 +58,7 @@ public Reader create(Reader reader) {
5858
}));
5959

6060
indicesAnalysisService.tokenizerFactories().put("kuromoji_tokenizer",
61-
new PreBuiltTokenizerFactoryFactory(new TokenizerFactory() {
61+
new KurumojiTokenizerFactoryFactory(new TokenizerFactory() {
6262
@Override
6363
public String name() {
6464
return "kuromoji_tokenizer";
@@ -72,7 +72,7 @@ public Tokenizer create(Reader reader) {
7272
}));
7373

7474
indicesAnalysisService.tokenFilterFactories().put("kuromoji_baseform",
75-
new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() {
75+
new KurumojiTokenFilterFactoryFactory(new TokenFilterFactory() {
7676
@Override
7777
public String name() {
7878
return "kuromoji_baseform";
@@ -86,7 +86,7 @@ public TokenStream create(TokenStream tokenStream) {
8686

8787
indicesAnalysisService.tokenFilterFactories().put(
8888
"kuromoji_part_of_speech",
89-
new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() {
89+
new KurumojiTokenFilterFactoryFactory(new TokenFilterFactory() {
9090
@Override
9191
public String name() {
9292
return "kuromoji_part_of_speech";
@@ -102,7 +102,7 @@ public TokenStream create(TokenStream tokenStream) {
102102

103103
indicesAnalysisService.tokenFilterFactories().put(
104104
"kuromoji_readingform",
105-
new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() {
105+
new KurumojiTokenFilterFactoryFactory(new TokenFilterFactory() {
106106
@Override
107107
public String name() {
108108
return "kuromoji_readingform";
@@ -115,7 +115,7 @@ public TokenStream create(TokenStream tokenStream) {
115115
}));
116116

117117
indicesAnalysisService.tokenFilterFactories().put("kuromoji_stemmer",
118-
new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() {
118+
new KurumojiTokenFilterFactoryFactory(new TokenFilterFactory() {
119119
@Override
120120
public String name() {
121121
return "kuromoji_stemmer";
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to Elasticsearch (the "Author") under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. Author licenses this
6+
* file to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.indices.analysis;
21+
22+
import org.elasticsearch.common.settings.Settings;
23+
import org.elasticsearch.index.analysis.CharFilterFactory;
24+
import org.elasticsearch.index.analysis.PreBuiltCharFilterFactoryFactory;
25+
26+
public class KurumojiCharFilterFactoryFactory extends PreBuiltCharFilterFactoryFactory {
27+
private final CharFilterFactory charFilterFactory;
28+
29+
public KurumojiCharFilterFactoryFactory(CharFilterFactory charFilterFactory) {
30+
super(charFilterFactory);
31+
this.charFilterFactory = charFilterFactory;
32+
}
33+
34+
@Override
35+
public CharFilterFactory create(String name, Settings settings) {
36+
return charFilterFactory;
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to Elasticsearch (the "Author") under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. Author licenses this
6+
* file to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.indices.analysis;
21+
22+
import org.elasticsearch.common.settings.Settings;
23+
import org.elasticsearch.index.analysis.PreBuiltTokenFilterFactoryFactory;
24+
import org.elasticsearch.index.analysis.TokenFilterFactory;
25+
26+
public class KurumojiTokenFilterFactoryFactory extends PreBuiltTokenFilterFactoryFactory {
27+
private final TokenFilterFactory tokenFilterFactory;
28+
29+
public KurumojiTokenFilterFactoryFactory(TokenFilterFactory tokenFilterFactory) {
30+
super(tokenFilterFactory);
31+
this.tokenFilterFactory = tokenFilterFactory;
32+
}
33+
34+
@Override
35+
public TokenFilterFactory create(String name, Settings settings) {
36+
return tokenFilterFactory;
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to Elasticsearch (the "Author") under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. Author licenses this
6+
* file to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.indices.analysis;
21+
22+
import org.elasticsearch.common.settings.Settings;
23+
import org.elasticsearch.index.analysis.PreBuiltTokenizerFactoryFactory;
24+
import org.elasticsearch.index.analysis.TokenizerFactory;
25+
26+
public class KurumojiTokenizerFactoryFactory extends PreBuiltTokenizerFactoryFactory {
27+
private final TokenizerFactory tokenizerFactory;
28+
29+
public KurumojiTokenizerFactoryFactory(TokenizerFactory tokenizerFactory) {
30+
super(tokenizerFactory);
31+
this.tokenizerFactory = tokenizerFactory;
32+
}
33+
34+
@Override
35+
public TokenizerFactory create(String name, Settings settings) {
36+
return tokenizerFactory;
37+
}
38+
}

0 commit comments

Comments
 (0)