Skip to content

Commit dc47913

Browse files
committed
update to Elasticsearch 5.3
1 parent 01293b0 commit dc47913

File tree

8 files changed

+39
-24
lines changed

8 files changed

+39
-24
lines changed

README.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Here is a list of languages code recognized:
8989
[frame="all"]
9090
|===
9191
| Plugin version | Elasticsearch version | Release date
92+
| 5.3.0.0 | 5.3.0 | Mar 30, 2017
9293
| 5.2.2.0 | 5.2.2 | Mar 2, 2017
9394
| 5.2.1.0 | 5.2.1 | Mar 2, 2017
9495
| 5.1.2.0 | 5.1.2 | Jan 26, 2017
@@ -119,7 +120,7 @@ Here is a list of languages code recognized:
119120

120121
[source]
121122
----
122-
./bin/elasticsearch-plugin install http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-langdetect/5.2.2.0/elasticsearch-langdetect-5.2.2.0-plugin.zip
123+
./bin/elasticsearch-plugin install http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-langdetect/5.3.0.0/elasticsearch-langdetect-5.3.0.0-plugin.zip
123124
----
124125

125126
### Elasticsearch 2.x

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
group = org.xbib.elasticsearch.plugin
22
name = elasticsearch-langdetect
3-
version = 5.2.2.0
3+
version = 5.3.0.0
44

5-
elasticsearch.version = 5.2.2
5+
elasticsearch.version = 5.3.0
66
log4j.version = 2.8
77
junit.version = 4.12
88
wagon-ssh-external.version = 2.10

src/main/java/org/xbib/elasticsearch/action/langdetect/LangdetectResponse.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import org.elasticsearch.action.ActionResponse;
44
import org.elasticsearch.common.Strings;
5-
import org.elasticsearch.common.xcontent.StatusToXContent;
5+
import org.elasticsearch.common.xcontent.StatusToXContentObject;
6+
import org.elasticsearch.common.xcontent.ToXContent;
67
import org.elasticsearch.common.xcontent.XContentBuilder;
78
import org.elasticsearch.rest.RestStatus;
89
import org.xbib.elasticsearch.common.langdetect.Language;
@@ -16,7 +17,7 @@
1617
/**
1718
*
1819
*/
19-
public class LangdetectResponse extends ActionResponse implements StatusToXContent {
20+
public class LangdetectResponse extends ActionResponse implements StatusToXContentObject {
2021

2122
private String profile;
2223

@@ -41,7 +42,7 @@ public LangdetectResponse setLanguages(List<Language> languages) {
4142
}
4243

4344
@Override
44-
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
45+
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
4546
if (!Strings.isNullOrEmpty(profile)) {
4647
builder.field("profile", profile);
4748
}

src/main/java/org/xbib/elasticsearch/index/mapper/langdetect/LangdetectMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public static class TypeParser implements Mapper.TypeParser {
435435
}
436436

437437
private static boolean parseStore(String store) throws MapperParsingException {
438-
return !"no".equals(store) && ("yes".equals(store) || lenientNodeBooleanValue(store));
438+
return !"no".equals(store) && ("yes".equals(store) || lenientNodeBooleanValue(null, store, false));
439439
}
440440
}
441441

src/main/java/org/xbib/elasticsearch/plugin/langdetect/LangdetectPlugin.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
import org.elasticsearch.action.ActionRequest;
44
import org.elasticsearch.action.ActionResponse;
5+
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
6+
import org.elasticsearch.cluster.node.DiscoveryNodes;
7+
import org.elasticsearch.common.settings.ClusterSettings;
8+
import org.elasticsearch.common.settings.IndexScopedSettings;
9+
import org.elasticsearch.common.settings.Settings;
10+
import org.elasticsearch.common.settings.SettingsFilter;
511
import org.elasticsearch.index.mapper.Mapper;
612
import org.elasticsearch.plugins.ActionPlugin;
713
import org.elasticsearch.plugins.MapperPlugin;
814
import org.elasticsearch.plugins.Plugin;
15+
import org.elasticsearch.rest.RestController;
916
import org.elasticsearch.rest.RestHandler;
1017
import org.xbib.elasticsearch.action.langdetect.LangdetectAction;
1118
import org.xbib.elasticsearch.action.langdetect.TransportLangdetectAction;
@@ -16,6 +23,7 @@
1623
import java.util.LinkedHashMap;
1724
import java.util.List;
1825
import java.util.Map;
26+
import java.util.function.Supplier;
1927

2028
/**
2129
*
@@ -37,9 +45,15 @@ public Map<String, Mapper.TypeParser> getMappers() {
3745
}
3846

3947
@Override
40-
public List<Class<? extends RestHandler>> getRestHandlers() {
41-
List<Class<? extends RestHandler>> extra = new ArrayList<>();
42-
extra.add(RestLangdetectAction.class);
48+
public List<RestHandler> getRestHandlers(Settings settings,
49+
RestController restController,
50+
ClusterSettings clusterSettings,
51+
IndexScopedSettings indexScopedSettings,
52+
SettingsFilter settingsFilter,
53+
IndexNameExpressionResolver indexNameExpressionResolver,
54+
Supplier<DiscoveryNodes> nodesInCluster) {
55+
List<RestHandler> extra = new ArrayList<>();
56+
extra.add(new RestLangdetectAction(settings, restController));
4357
return extra;
4458
}
4559
}

src/test/java/org/elasticsearch/node/MockNode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.elasticsearch.node;
22

33
import org.elasticsearch.common.settings.Settings;
4-
import org.elasticsearch.node.internal.InternalSettingsPreparer;
54
import org.elasticsearch.plugins.Plugin;
65

76
import java.util.ArrayList;

src/test/java/org/xbib/elasticsearch/MapperTestUtils.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class MapperTestUtils {
3838

3939
public static AnalysisRegistry analysisService(Settings customSettings) throws IOException {
4040
Settings settings = Settings.builder()
41-
.put("path.home", System.getProperty("path.home", "/tmp"))
41+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
4242
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
4343
.put(customSettings)
4444
.build();
@@ -53,7 +53,7 @@ public static DocumentMapperParser newDocumentMapperParser(String index) throws
5353

5454
public static DocumentMapperParser newDocumentMapperParser(Settings customSettings, String index) throws IOException {
5555
Settings settings = Settings.builder()
56-
.put("path.home", System.getProperty("path.home", "/tmp"))
56+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
5757
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
5858
.put(customSettings)
5959
.build();
@@ -90,7 +90,7 @@ public static DocumentMapperParser newDocumentMapperParser(Settings customSettin
9090
public static Analyzer analyzer(String name) throws IOException {
9191
Settings settings = Settings.builder()
9292
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
93-
.put("path.home", System.getProperty("path.home"))
93+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
9494
.build();
9595
AnalysisRegistry analysisRegistry = analysisService(settings);
9696
IndexMetaData indexMetaData = IndexMetaData.builder("test")
@@ -114,7 +114,7 @@ public static Analyzer analyzer(String name) throws IOException {
114114
public static Analyzer analyzer(Settings customSettings, String name) throws IOException {
115115
Settings settings = Settings.builder()
116116
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
117-
.put("path.home", System.getProperty("path.home", "/tmp"))
117+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
118118
.put(customSettings)
119119
.build();
120120
AnalysisRegistry analysisRegistry = analysisService(settings);
@@ -139,7 +139,7 @@ public static Analyzer analyzer(Settings customSettings, String name) throws IOE
139139
public static Analyzer analyzer(String resource, String name) throws IOException {
140140
Settings settings = Settings.builder()
141141
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
142-
.put("path.home", System.getProperty("path.home", "/tmp"))
142+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
143143
.loadFromStream(resource, MapperTestUtils.class.getClassLoader().getResource(resource).openStream())
144144
.build();
145145
AnalysisRegistry analysisRegistry = analysisService(settings);
@@ -164,7 +164,7 @@ public static Analyzer analyzer(String resource, String name) throws IOException
164164
public static TokenizerFactory tokenizerFactory(String name) throws IOException {
165165
Settings settings = Settings.builder()
166166
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
167-
.put("path.home", System.getProperty("path.home", "/tmp"))
167+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
168168
.build();
169169
AnalysisRegistry analysisRegistry = analysisService(settings);
170170
IndexMetaData indexMetaData = IndexMetaData.builder("test")
@@ -183,7 +183,7 @@ public static TokenizerFactory tokenizerFactory(String name) throws IOException
183183
public static TokenizerFactory tokenizerFactory(String resource, String name) throws IOException {
184184
Settings settings = Settings.builder()
185185
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
186-
.put("path.home", System.getProperty("path.home"))
186+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
187187
.loadFromStream(resource, MapperTestUtils.class.getClassLoader().getResource(resource).openStream())
188188
.build();
189189
Environment environment = new Environment(settings);
@@ -204,7 +204,7 @@ public static TokenizerFactory tokenizerFactory(String resource, String name) th
204204
public static TokenFilterFactory tokenFilterFactory(String name) throws IOException {
205205
Settings settings = Settings.builder()
206206
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
207-
.put("path.home", System.getProperty("path.home", "/tmp"))
207+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
208208
.build();
209209
Environment environment = new Environment(settings);
210210
AnalysisRegistry analysisRegistry = analysisService(settings);
@@ -222,7 +222,7 @@ public static TokenFilterFactory tokenFilterFactory(String name) throws IOExcept
222222
public static TokenFilterFactory tokenFilterFactory(String resource, String name) throws IOException {
223223
Settings settings = Settings.builder()
224224
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
225-
.put("path.home", System.getProperty("path.home", "/tmp"))
225+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
226226
.loadFromStream(resource, MapperTestUtils.class.getClassLoader().getResource(resource).openStream())
227227
.build();
228228
Environment environment = new Environment(settings);
@@ -241,7 +241,7 @@ public static TokenFilterFactory tokenFilterFactory(String resource, String name
241241
public static CharFilterFactory charFilterFactory(String name) throws IOException {
242242
Settings settings = Settings.builder()
243243
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
244-
.put("path.home", System.getProperty("path.home", "/tmp"))
244+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
245245
.build();
246246
Environment environment = new Environment(settings);
247247
AnalysisRegistry analysisRegistry = analysisService(settings);
@@ -259,7 +259,7 @@ public static CharFilterFactory charFilterFactory(String name) throws IOExceptio
259259
public static CharFilterFactory charFilterFactory(String resource, String name) throws IOException {
260260
Settings settings = Settings.builder()
261261
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
262-
.put("path.home", System.getProperty("path.home", "/tmp"))
262+
.put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
263263
.loadFromStream(resource, MapperTestUtils.class.getClassLoader().getResource(resource).openStream())
264264
.build();
265265
Environment environment = new Environment(settings);

src/test/java/org/xbib/elasticsearch/NodeTestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ public Node buildNode() throws IOException {
185185
}
186186

187187

188-
private static void deleteFiles() throws IOException {
189-
Path directory = Paths.get(System.getProperty("path.home") + "/data");
188+
private void deleteFiles() throws IOException {
189+
Path directory = Paths.get(getHome() + "/data");
190190
Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
191191
@Override
192192
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

0 commit comments

Comments
 (0)