|
|
@@ -22,10 +22,14 @@ package org.elasticsearch.mapper.attachments;
|
|
|
import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
|
import org.elasticsearch.common.bytes.BytesReference;
|
|
|
+import org.elasticsearch.common.compress.CompressedXContent;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
+import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.index.mapper.DocumentMapper;
|
|
|
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
|
|
+import org.elasticsearch.index.mapper.MapperService;
|
|
|
import org.elasticsearch.index.mapper.ParseContext;
|
|
|
+import org.junit.Test;
|
|
|
|
|
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
|
|
import static org.elasticsearch.test.StreamsUtils.copyToBytesFromClasspath;
|
|
|
@@ -107,4 +111,32 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase {
|
|
|
assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content"));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * See issue https://github.com/elastic/elasticsearch-mapper-attachments/issues/169
|
|
|
+ * Mapping should not contain field names with dot.
|
|
|
+ */
|
|
|
+ public void testMapperErrorWithDotTwoLevels169() throws Exception {
|
|
|
+ XContentBuilder mappingBuilder = jsonBuilder();
|
|
|
+ mappingBuilder.startObject()
|
|
|
+ .startObject("mail")
|
|
|
+ .startObject("properties")
|
|
|
+ .startObject("attachments")
|
|
|
+ .startObject("properties")
|
|
|
+ .startObject("innerfield")
|
|
|
+ .field("type", "attachment")
|
|
|
+ .endObject()
|
|
|
+ .endObject()
|
|
|
+ .endObject()
|
|
|
+ .endObject()
|
|
|
+ .endObject();
|
|
|
+
|
|
|
+ byte[] mapping = mappingBuilder.bytes().toBytes();
|
|
|
+ MapperService mapperService = MapperTestUtils.newMapperService(createTempDir(), Settings.EMPTY);
|
|
|
+ DocumentMapper docMapper = mapperService.parse("mail", new CompressedXContent(mapping), true);
|
|
|
+ // this should not throw an exception
|
|
|
+ mapperService.parse("mail", new CompressedXContent(docMapper.mapping().toString()), true);
|
|
|
+ // the mapping may not contain a field name with a dot
|
|
|
+ assertFalse(docMapper.mapping().toString().contains("."));
|
|
|
+ }
|
|
|
+
|
|
|
}
|