Skip to content

Commit e1fe893

Browse files
committed
change mappersAdded flag to mappingsModified to better reflect any possible change in mappings, not just additions
1 parent 79cb0ea commit e1fe893

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected PrimaryResponse<BulkShardResponse, BulkShardRequest> shardOperationOnP
168168
indexRequest.version(version);
169169

170170
// update mapping on master if needed, we won't update changes to the same type, since once its changed, it won't have mappers added
171-
if (op.parsedDoc().mappersAdded()) {
171+
if (op.parsedDoc().mappingsModified()) {
172172
if (mappingsToUpdate == null) {
173173
mappingsToUpdate = Sets.newHashSet();
174174
}

src/main/java/org/elasticsearch/action/index/TransportIndexAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected PrimaryResponse<IndexResponse, IndexRequest> shardOperationOnPrimary(C
222222
// ignore
223223
}
224224
}
225-
if (op.parsedDoc().mappersAdded()) {
225+
if (op.parsedDoc().mappingsModified()) {
226226
updateMappingOnMaster(request);
227227
}
228228
// update the version on the request, so it will be used for the replicas

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public ParsedDocument parse(SourceToParse source, @Nullable ParseListener listen
454454
context.reset(parser, new Document(), source, listener);
455455
// on a newly created instance of document mapper, we always consider it as new mappers that have been added
456456
if (initMappersAdded) {
457-
context.addedMapper();
457+
context.setMappingsModified();
458458
initMappersAdded = false;
459459
}
460460

@@ -518,7 +518,7 @@ public ParsedDocument parse(SourceToParse source, @Nullable ParseListener listen
518518
Collections.reverse(context.docs());
519519
}
520520
ParsedDocument doc = new ParsedDocument(context.uid(), context.id(), context.type(), source.routing(), source.timestamp(), source.ttl(), context.docs(), context.analyzer(),
521-
context.source(), context.mappersAdded()).parent(source.parent());
521+
context.source(), context.mappingsModified()).parent(source.parent());
522522
// reset the context to free up memory
523523
context.reset(null, null, null, null);
524524
return doc;

src/main/java/org/elasticsearch/index/mapper/ParseContext.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class ParseContext {
7272

7373
private Map<String, String> ignoredValues = new HashMap<String, String>();
7474

75-
private boolean mappersAdded = false;
75+
private boolean mappingsModified = false;
7676

7777
private boolean externalValueSet;
7878

@@ -103,7 +103,7 @@ public void reset(XContentParser parser, Document document, SourceToParse source
103103
this.sourceToParse = source;
104104
this.source = source == null ? null : sourceToParse.source();
105105
this.path.reset();
106-
this.mappersAdded = false;
106+
this.mappingsModified = false;
107107
this.listener = listener == null ? DocumentMapper.ParseListener.EMPTY : listener;
108108
this.allEntries = new AllEntries();
109109
this.ignoredValues.clear();
@@ -117,12 +117,12 @@ public DocumentMapperParser docMapperParser() {
117117
return this.docMapperParser;
118118
}
119119

120-
public boolean mappersAdded() {
121-
return this.mappersAdded;
120+
public boolean mappingsModified() {
121+
return this.mappingsModified;
122122
}
123123

124-
public void addedMapper() {
125-
this.mappersAdded = true;
124+
public void setMappingsModified() {
125+
this.mappingsModified = true;
126126
}
127127

128128
public String index() {

src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ public class ParsedDocument {
4949

5050
private final BytesReference source;
5151

52-
private boolean mappersAdded;
52+
private boolean mappingsModified;
5353

5454
private String parent;
5555

56-
public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, Document document, Analyzer analyzer, BytesReference source, boolean mappersAdded) {
57-
this(uid, id, type, routing, timestamp, ttl, Arrays.asList(document), analyzer, source, mappersAdded);
56+
public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, Document document, Analyzer analyzer, BytesReference source, boolean mappingsModified) {
57+
this(uid, id, type, routing, timestamp, ttl, Arrays.asList(document), analyzer, source, mappingsModified);
5858
}
5959

60-
public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, List<Document> documents, Analyzer analyzer, BytesReference source, boolean mappersAdded) {
60+
public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, List<Document> documents, Analyzer analyzer, BytesReference source, boolean mappingsModified) {
6161
this.uid = uid;
6262
this.id = id;
6363
this.type = type;
@@ -67,7 +67,7 @@ public ParsedDocument(String uid, String id, String type, String routing, long t
6767
this.documents = documents;
6868
this.source = source;
6969
this.analyzer = analyzer;
70-
this.mappersAdded = mappersAdded;
70+
this.mappingsModified = mappingsModified;
7171
}
7272

7373
public String uid() {
@@ -120,10 +120,10 @@ public String parent() {
120120
}
121121

122122
/**
123-
* Has the parsed document caused for new mappings to be added.
123+
* Has the parsed document caused mappings to be modified?
124124
*/
125-
public boolean mappersAdded() {
126-
return mappersAdded;
125+
public boolean mappingsModified() {
126+
return mappingsModified;
127127
}
128128

129129
public String toString() {

src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ private void serializeObject(final ParseContext context, String currentFieldName
521521
putMapper(objectMapper);
522522
// now re add it
523523
context.path().add(currentFieldName);
524-
context.addedMapper();
524+
context.setMappingsModified();
525525
}
526526
}
527527
// traverse and parse outside of the mutex
@@ -757,7 +757,7 @@ private void serializeValue(final ParseContext context, String currentFieldName,
757757
}
758758
}
759759
putMapper(mapper);
760-
context.addedMapper();
760+
context.setMappingsModified();
761761
}
762762
}
763763
if (newMapper) {

src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ private Response percolate(DocAndQueryRequest request) throws ElasticSearchExcep
362362
indexCache.clear(searcher.getIndexReader());
363363
}
364364

365-
return new Response(matches, request.doc().mappersAdded());
365+
return new Response(matches, request.doc().mappingsModified());
366366
}
367367

368368
private IndexService percolatorIndexServiceSafe() {

0 commit comments

Comments
 (0)