Skip to content

Commit 8a8a6d5

Browse files
committed
Mapping: Rename _attributes to _meta, closes elastic#518.
1 parent b8b4cbb commit 8a8a6d5

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface DocumentMapper {
4545
/**
4646
* Attributes of this type mappings.
4747
*/
48-
ImmutableMap<String, Object> attributes();
48+
ImmutableMap<String, Object> meta();
4949

5050
/**
5151
* Generates the source of the mapper based on the current mappings.

modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapper.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static class Builder {
7070

7171
private final RootObjectMapper rootObjectMapper;
7272

73-
private ImmutableMap<String, Object> attributes = ImmutableMap.of();
73+
private ImmutableMap<String, Object> meta = ImmutableMap.of();
7474

7575
private XContentMapper.BuilderContext builderContext = new XContentMapper.BuilderContext(new ContentPath(1));
7676

@@ -79,8 +79,8 @@ public Builder(String index, RootObjectMapper.Builder builder) {
7979
this.rootObjectMapper = builder.build(builderContext);
8080
}
8181

82-
public Builder attributes(ImmutableMap<String, Object> attributes) {
83-
this.attributes = attributes;
82+
public Builder meta(ImmutableMap<String, Object> meta) {
83+
this.meta = meta;
8484
return this;
8585
}
8686

@@ -149,7 +149,7 @@ public boolean hasSearchAnalyzer() {
149149

150150
public XContentDocumentMapper build(XContentDocumentMapperParser docMapperParser) {
151151
Preconditions.checkNotNull(rootObjectMapper, "Mapper builder must have the root object mapper set");
152-
return new XContentDocumentMapper(index, docMapperParser, rootObjectMapper, attributes, uidFieldMapper, idFieldMapper, typeFieldMapper, indexFieldMapper,
152+
return new XContentDocumentMapper(index, docMapperParser, rootObjectMapper, meta, uidFieldMapper, idFieldMapper, typeFieldMapper, indexFieldMapper,
153153
sourceFieldMapper, routingFieldMapper, allFieldMapper, analyzerMapper, indexAnalyzer, searchAnalyzer, boostFieldMapper);
154154
}
155155
}
@@ -167,7 +167,7 @@ public XContentDocumentMapper build(XContentDocumentMapperParser docMapperParser
167167

168168
private final XContentDocumentMapperParser docMapperParser;
169169

170-
private volatile ImmutableMap<String, Object> attributes;
170+
private volatile ImmutableMap<String, Object> meta;
171171

172172
private volatile CompressedString mappingSource;
173173

@@ -205,7 +205,7 @@ public XContentDocumentMapper build(XContentDocumentMapperParser docMapperParser
205205

206206
public XContentDocumentMapper(String index, XContentDocumentMapperParser docMapperParser,
207207
RootObjectMapper rootObjectMapper,
208-
ImmutableMap<String, Object> attributes,
208+
ImmutableMap<String, Object> meta,
209209
UidFieldMapper uidFieldMapper,
210210
IdFieldMapper idFieldMapper,
211211
TypeFieldMapper typeFieldMapper,
@@ -219,7 +219,7 @@ public XContentDocumentMapper(String index, XContentDocumentMapperParser docMapp
219219
this.index = index;
220220
this.type = rootObjectMapper.name();
221221
this.docMapperParser = docMapperParser;
222-
this.attributes = attributes;
222+
this.meta = meta;
223223
this.rootObjectMapper = rootObjectMapper;
224224
this.uidFieldMapper = uidFieldMapper;
225225
this.idFieldMapper = idFieldMapper;
@@ -272,8 +272,8 @@ public XContentDocumentMapper(String index, XContentDocumentMapperParser docMapp
272272
return this.type;
273273
}
274274

275-
@Override public ImmutableMap<String, Object> attributes() {
276-
return this.attributes;
275+
@Override public ImmutableMap<String, Object> meta() {
276+
return this.meta;
277277
}
278278

279279
@Override public CompressedString mappingSource() {
@@ -448,7 +448,7 @@ void addFieldMapper(FieldMapper fieldMapper) {
448448
rootObjectMapper.merge(xContentMergeWith.rootObjectMapper, mergeContext);
449449
if (!mergeFlags.simulate()) {
450450
// let the merge with attributes to override the attributes
451-
attributes = mergeWith.attributes();
451+
meta = mergeWith.meta();
452452
// update the source of the merged one
453453
refreshSource();
454454
}
@@ -488,8 +488,8 @@ void addFieldMapper(FieldMapper fieldMapper) {
488488
}
489489
}
490490

491-
if (attributes != null && !attributes.isEmpty()) {
492-
builder.field("_attributes", attributes());
491+
if (meta != null && !meta.isEmpty()) {
492+
builder.field("_meta", meta());
493493
}
494494
}
495495
// no need to pass here id and boost, since they are added to the root object mapper

modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ public XContentMapper.TypeParser.ParserContext parserContext() {
172172
}
173173

174174
ImmutableMap<String, Object> attributes = ImmutableMap.of();
175-
if (mapping.containsKey("_attributes")) {
176-
attributes = ImmutableMap.copyOf((Map<String, Object>) mapping.get("_attributes"));
175+
if (mapping.containsKey("_meta")) {
176+
attributes = ImmutableMap.copyOf((Map<String, Object>) mapping.get("_meta"));
177177
}
178-
docBuilder.attributes(attributes);
178+
docBuilder.meta(attributes);
179179

180180
XContentDocumentMapper documentMapper = docBuilder.build(this);
181181
// update the source with the generated one

modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/SimpleMapperTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class SimpleMapperTests {
7979
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json");
8080
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
8181

82-
assertThat((String) docMapper.attributes().get("param1"), equalTo("value1"));
82+
assertThat((String) docMapper.meta().get("param1"), equalTo("value1"));
8383

8484
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test1.json");
8585
Document doc = docMapper.parse(json).doc();
@@ -108,10 +108,10 @@ public class SimpleMapperTests {
108108
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json");
109109
XContentDocumentMapper docMapper = MapperTests.newParser().parse(mapping);
110110

111-
assertThat((String) docMapper.attributes().get("param1"), equalTo("value1"));
111+
assertThat((String) docMapper.meta().get("param1"), equalTo("value1"));
112112

113113
String builtMapping = docMapper.mappingSource().string();
114114
XContentDocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping);
115-
assertThat((String) builtDocMapper.attributes().get("param1"), equalTo("value1"));
115+
assertThat((String) builtDocMapper.meta().get("param1"), equalTo("value1"));
116116
}
117117
}

modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/simple/test-mapping.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
person : {
3-
"_attributes" : {
3+
"_meta" : {
44
"param1" : "value1"
55
},
66
date_formats : ["yyyy-MM-dd", "dd-MM-yyyy"],

0 commit comments

Comments
 (0)