Skip to content

Commit

Permalink
Update to ES 5.4.1.
Browse files Browse the repository at this point in the history
Made a few adoptions to minor changes in the ES API, just to avoid
deprecation warnings.
  • Loading branch information
khituras committed Jun 13, 2017
1 parent ac2cbe5 commit 6ca8762
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ ElasticSearch compatibility table:

| elasticsearch | Preanalyzed Mapper Plugin | Docs
|---------------|----------------------------|------
| es-5.4.0     | 5.4.0 | [5.4.0] (https://github.com/khituras/elasticsearch-mapper-preanalyzed/tree/master)
| es-5.4.1     | 5.4.1 | [5.4.1] (https://github.com/khituras/elasticsearch-mapper-preanalyzed/tree/master)
| es-5.4.0     | 5.4.0 | [5.4.0] (https://github.com/khituras/elasticsearch-mapper-preanalyzed/tree/es-5.4.0)
| es-5.3.2     | 5.3.2 | [5.3.2] (https://github.com/khituras/elasticsearch-mapper-preanalyzed/tree/es-5.3.2)
| es-5.3.1     | 5.3.1 | [5.3.1] (https://github.com/khituras/elasticsearch-mapper-preanalyzed/tree/es-5.3.1)
| es-5.3.0 | 5.3.0 | [5.3.0] (https://github.com/khituras/elasticsearch-mapper-preanalyzed/tree/es-5.3.0)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ apply plugin: 'eclipse'
apply plugin: 'signing'

group = 'de.julielab'
version = '5.4.0'
version = '5.4.1'

esplugin {
name 'elasticsearch-mapper-preanalyzed'
description 'This plugin allows to send field data in a preanalyzed format to ElasticSearch. No analysis will be done by ElasticSearch, the format defines all terms specifically.'
classname 'org.elasticsearch.index.plugin.mapper.preanalyzed.MapperPreAnalyzedPlugin'
version '5.4.0'
version '5.4.1'
}

description = """ElasticSearch Preanalyzed Mapper Plugin"""
Expand All @@ -35,7 +35,7 @@ buildscript {
}

dependencies {
classpath "org.elasticsearch.gradle:build-tools:5.4.0"
classpath "org.elasticsearch.gradle:build-tools:5.4.1"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.DocumentMapperParser;
Expand Down Expand Up @@ -235,7 +236,7 @@ public void testPreAnalyzedTokenStream() throws IOException {
.field("y", "testtype").field("f", "0x4").endObject();

tsBuilder.endArray().endObject();
XContentParser parser = XContentHelper.createParser(NamedXContentRegistry.EMPTY, tsBuilder.bytes());
XContentParser parser = XContentHelper.createParser(NamedXContentRegistry.EMPTY, tsBuilder.bytes(), XContentType.JSON);
parser.nextToken(); // begin object
parser.nextToken();
assertEquals(XContentParser.Token.FIELD_NAME, parser.currentToken()); // "v"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.plugin.mapper.preanalyzed.MapperPreAnalyzedPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.SearchHit;
Expand Down Expand Up @@ -65,7 +66,7 @@ public void testAnalysis() throws Exception {
// test resources into the build folder
String mapping = IOUtils.toString(getClass().getResourceAsStream("/simpleMapping.json"), "UTF-8");
// Put the preanalyzed mapping
client().admin().indices().putMapping(putMappingRequest("test").type("document").source(mapping)).actionGet();
client().admin().indices().putMapping(putMappingRequest("test").type("document").source(mapping, XContentType.JSON)).actionGet();
assertEquals("Black", client().admin().indices().prepareAnalyze("Black").setIndex("test").setField("title")
.execute().get().getTokens().get(0).getTerm());
}
Expand All @@ -78,7 +79,7 @@ public void testSimpleIndex() throws Exception {
byte[] docBytes = IOUtils.toByteArray(getClass().getResourceAsStream("/preanalyzedDoc.json"));

// Put the preanalyzed mapping check that it is there indeed
client().admin().indices().putMapping(putMappingRequest("test").type("document").source(mapping)).actionGet();
client().admin().indices().putMapping(putMappingRequest("test").type("document").source(mapping, XContentType.JSON)).actionGet();
GetMappingsResponse actionGet = client().admin().indices().getMappings(new GetMappingsRequest().indices("test"))
.get();
Map<String, Object> mappingProperties = (Map<String, Object>) actionGet.getMappings().get("test")
Expand All @@ -90,7 +91,7 @@ public void testSimpleIndex() throws Exception {
assertEquals("with_positions_offsets", titleMapping.get("term_vector"));
assertEquals("keyword", titleMapping.get("analyzer"));

index("test", "document", "1", XContentHelper.convertToJson(new BytesArray(docBytes), false, false));
index("test", "document", "1", XContentHelper.convertToJson(new BytesArray(docBytes), false, XContentType.JSON));
refresh();

SearchResponse searchResponse = client().prepareExecute(SearchAction.INSTANCE)
Expand Down Expand Up @@ -134,6 +135,6 @@ public void testSimpleIndex() throws Exception {
.execute().actionGet();
assertEquals(1, searchResponse.getHits().getTotalHits());
SearchHit searchHit = searchResponse.getHits().getHits()[0];
assertTrue(((String) searchHit.field("title").value()).startsWith("Black Beauty"));
assertTrue(((String) searchHit.getField("title").getValue()).startsWith("Black Beauty"));
}
}

0 comments on commit 6ca8762

Please sign in to comment.