Skip to content

Commit 8ad05fd

Browse files
committed
re-enable langdetect field store attribute, set default to true
1 parent 0938773 commit 8ad05fd

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
group = org.xbib.elasticsearch.plugin
22
name = elasticsearch-langdetect
3-
version = 5.4.0.0
3+
version = 5.4.0.1
44

55
elasticsearch.version = 5.4.0
66
log4j.version = 2.8.2

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(null, store, false));
438+
return !"no".equals(store) && ("yes".equals(store) || lenientNodeBooleanValue(null, store, true));
439439
}
440440
}
441441

src/test/java/org/xbib/elasticsearch/index/mapper/langdetect/LangdetectMappingTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ public void testCustomMappings() throws Exception {
6868
assertEquals("Deutsch", doc.getFields("someField")[0].stringValue());
6969
}
7070

71+
@Test
72+
public void testStoreMappings() throws Exception {
73+
Settings settings = Settings.builder()
74+
.put("path.home", System.getProperty("path.home"))
75+
.loadFromStream("settings.json", getClass().getResourceAsStream("settings.json")).build();
76+
String mapping = copyToStringFromClasspath("mapping-stored.json");
77+
DocumentMapper docMapper = MapperTestUtils.newDocumentMapperParser(settings, "someIndex").parse("someType", new CompressedXContent(mapping));
78+
String sampleText = copyToStringFromClasspath("german.txt");
79+
BytesReference json = jsonBuilder().startObject().field("someField", sampleText).endObject().bytes();
80+
ParseContext.Document doc = docMapper.parse("someIndex", "someType", "1", json).rootDoc();
81+
assertEquals(1, doc.getFields("someField").length);
82+
assertTrue(doc.getFields("someField")[0].fieldType().stored());
83+
}
84+
7185
@Test
7286
public void testBinary2() throws Exception {
7387
String mapping = copyToStringFromClasspath("base64-2-mapping.json");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"someType" : {
3+
"properties" : {
4+
"someField":{
5+
"type" : "langdetect",
6+
"store": true,
7+
"languages" : [ "de", "en", "fr", "nl", "it" ],
8+
"map" : {
9+
"de" : "Deutsch"
10+
}
11+
}
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)