From 8a8a6d5547776776494194d83f280ad9caa7fc42 Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 16 Nov 2010 01:34:01 +0200 Subject: [PATCH] Mapping: Rename _attributes to _meta, closes #518. --- .../index/mapper/DocumentMapper.java | 2 +- .../xcontent/XContentDocumentMapper.java | 24 +++++++++---------- .../XContentDocumentMapperParser.java | 6 ++--- .../xcontent/simple/SimpleMapperTests.java | 6 ++--- .../mapper/xcontent/simple/test-mapping.json | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java index 19ec4579ff8..5f690cf9929 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java @@ -45,7 +45,7 @@ public interface DocumentMapper { /** * Attributes of this type mappings. */ - ImmutableMap attributes(); + ImmutableMap meta(); /** * Generates the source of the mapper based on the current mappings. diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapper.java index 7edf95ec8b6..c386f6561fe 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapper.java @@ -70,7 +70,7 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { private final RootObjectMapper rootObjectMapper; - private ImmutableMap attributes = ImmutableMap.of(); + private ImmutableMap meta = ImmutableMap.of(); private XContentMapper.BuilderContext builderContext = new XContentMapper.BuilderContext(new ContentPath(1)); @@ -79,8 +79,8 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { this.rootObjectMapper = builder.build(builderContext); } - public Builder attributes(ImmutableMap attributes) { - this.attributes = attributes; + public Builder meta(ImmutableMap meta) { + this.meta = meta; return this; } @@ -149,7 +149,7 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { public XContentDocumentMapper build(XContentDocumentMapperParser docMapperParser) { Preconditions.checkNotNull(rootObjectMapper, "Mapper builder must have the root object mapper set"); - return new XContentDocumentMapper(index, docMapperParser, rootObjectMapper, attributes, uidFieldMapper, idFieldMapper, typeFieldMapper, indexFieldMapper, + return new XContentDocumentMapper(index, docMapperParser, rootObjectMapper, meta, uidFieldMapper, idFieldMapper, typeFieldMapper, indexFieldMapper, sourceFieldMapper, routingFieldMapper, allFieldMapper, analyzerMapper, indexAnalyzer, searchAnalyzer, boostFieldMapper); } } @@ -167,7 +167,7 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { private final XContentDocumentMapperParser docMapperParser; - private volatile ImmutableMap attributes; + private volatile ImmutableMap meta; private volatile CompressedString mappingSource; @@ -205,7 +205,7 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { public XContentDocumentMapper(String index, XContentDocumentMapperParser docMapperParser, RootObjectMapper rootObjectMapper, - ImmutableMap attributes, + ImmutableMap meta, UidFieldMapper uidFieldMapper, IdFieldMapper idFieldMapper, TypeFieldMapper typeFieldMapper, @@ -219,7 +219,7 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { this.index = index; this.type = rootObjectMapper.name(); this.docMapperParser = docMapperParser; - this.attributes = attributes; + this.meta = meta; this.rootObjectMapper = rootObjectMapper; this.uidFieldMapper = uidFieldMapper; this.idFieldMapper = idFieldMapper; @@ -272,8 +272,8 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { return this.type; } - @Override public ImmutableMap attributes() { - return this.attributes; + @Override public ImmutableMap meta() { + return this.meta; } @Override public CompressedString mappingSource() { @@ -448,7 +448,7 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { rootObjectMapper.merge(xContentMergeWith.rootObjectMapper, mergeContext); if (!mergeFlags.simulate()) { // let the merge with attributes to override the attributes - attributes = mergeWith.attributes(); + meta = mergeWith.meta(); // update the source of the merged one refreshSource(); } @@ -488,8 +488,8 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent { } } - if (attributes != null && !attributes.isEmpty()) { - builder.field("_attributes", attributes()); + if (meta != null && !meta.isEmpty()) { + builder.field("_meta", meta()); } } // no need to pass here id and boost, since they are added to the root object mapper diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java index ad2df02b788..a80f96ac11b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java @@ -172,10 +172,10 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme } ImmutableMap attributes = ImmutableMap.of(); - if (mapping.containsKey("_attributes")) { - attributes = ImmutableMap.copyOf((Map) mapping.get("_attributes")); + if (mapping.containsKey("_meta")) { + attributes = ImmutableMap.copyOf((Map) mapping.get("_meta")); } - docBuilder.attributes(attributes); + docBuilder.meta(attributes); XContentDocumentMapper documentMapper = docBuilder.build(this); // update the source with the generated one diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/SimpleMapperTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/SimpleMapperTests.java index 5a9f15fe6c5..6350c8b8f3f 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/SimpleMapperTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/SimpleMapperTests.java @@ -79,7 +79,7 @@ public class SimpleMapperTests { String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json"); XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping); - assertThat((String) docMapper.attributes().get("param1"), equalTo("value1")); + assertThat((String) docMapper.meta().get("param1"), equalTo("value1")); byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test1.json"); Document doc = docMapper.parse(json).doc(); @@ -108,10 +108,10 @@ public class SimpleMapperTests { String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json"); XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping); - assertThat((String) docMapper.attributes().get("param1"), equalTo("value1")); + assertThat((String) docMapper.meta().get("param1"), equalTo("value1")); String builtMapping = docMapper.mappingSource().string(); XContentDocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping); - assertThat((String) builtDocMapper.attributes().get("param1"), equalTo("value1")); + assertThat((String) builtDocMapper.meta().get("param1"), equalTo("value1")); } } diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json b/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json index 82d263e8d45..f7f6811ac60 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json @@ -1,6 +1,6 @@ { person : { - "_attributes" : { + "_meta" : { "param1" : "value1" }, date_formats : ["yyyy-MM-dd", "dd-MM-yyyy"],