diff --git a/x-pack/plugin/mapper-counted-keyword/src/main/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapper.java b/x-pack/plugin/mapper-counted-keyword/src/main/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapper.java index a7f8a47e4246..d04bb88325cc 100644 --- a/x-pack/plugin/mapper-counted-keyword/src/main/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapper.java +++ b/x-pack/plugin/mapper-counted-keyword/src/main/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapper.java @@ -281,7 +281,7 @@ public FieldMapper build(MapperBuilderContext context) { name, FIELD_TYPE, new CountedKeywordFieldType( - name, + context.buildFullName(name), true, false, true, diff --git a/x-pack/plugin/mapper-counted-keyword/src/test/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapperTests.java b/x-pack/plugin/mapper-counted-keyword/src/test/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapperTests.java index 9d1935a835cb..1468ed456b13 100644 --- a/x-pack/plugin/mapper-counted-keyword/src/test/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapperTests.java +++ b/x-pack/plugin/mapper-counted-keyword/src/test/java/org/elasticsearch/xpack/countedkeyword/CountedKeywordFieldMapperTests.java @@ -7,8 +7,11 @@ package org.elasticsearch.xpack.countedkeyword; +import org.apache.lucene.index.IndexableField; +import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperTestCase; +import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xcontent.XContentBuilder; import org.junit.AssumptionViolatedException; @@ -16,6 +19,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; +import java.util.List; public class CountedKeywordFieldMapperTests extends MapperTestCase { @Override @@ -67,4 +71,15 @@ protected SyntheticSourceSupport syntheticSourceSupport(boolean ignoreMalformed) protected IngestScriptSupport ingestScriptSupport() { throw new AssumptionViolatedException("not supported"); } + + public void testDottedFieldNames() throws IOException { + DocumentMapper mapper = createDocumentMapper(mapping(b -> { + b.startObject("dotted.field"); + b.field("type", CountedKeywordFieldMapper.CONTENT_TYPE); + b.endObject(); + })); + ParsedDocument doc = mapper.parse(source(b -> b.field("dotted.field", "1234"))); + List fields = doc.rootDoc().getFields("dotted.field"); + assertEquals(1, fields.size()); + } }