From e1fe89389c4e6f81a59bbb4b6790ee18410ae895 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 20 Aug 2012 13:36:28 +0200 Subject: [PATCH] change mappersAdded flag to mappingsModified to better reflect any possible change in mappings, not just additions --- .../action/bulk/TransportShardBulkAction.java | 2 +- .../action/index/TransportIndexAction.java | 2 +- .../index/mapper/DocumentMapper.java | 4 ++-- .../elasticsearch/index/mapper/ParseContext.java | 12 ++++++------ .../index/mapper/ParsedDocument.java | 16 ++++++++-------- .../index/mapper/object/ObjectMapper.java | 4 ++-- .../index/percolator/PercolatorExecutor.java | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index bd6b539e403..eab333b094c 100644 --- a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -168,7 +168,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation indexRequest.version(version); // 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 - if (op.parsedDoc().mappersAdded()) { + if (op.parsedDoc().mappingsModified()) { if (mappingsToUpdate == null) { mappingsToUpdate = Sets.newHashSet(); } diff --git a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java index a4d40348e7e..21b9df82fc5 100644 --- a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java +++ b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java @@ -222,7 +222,7 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi // ignore } } - if (op.parsedDoc().mappersAdded()) { + if (op.parsedDoc().mappingsModified()) { updateMappingOnMaster(request); } // update the version on the request, so it will be used for the replicas diff --git a/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java index c05e2aea4c2..e9886d70de5 100644 --- a/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java @@ -454,7 +454,7 @@ public class DocumentMapper implements ToXContent { context.reset(parser, new Document(), source, listener); // on a newly created instance of document mapper, we always consider it as new mappers that have been added if (initMappersAdded) { - context.addedMapper(); + context.setMappingsModified(); initMappersAdded = false; } @@ -518,7 +518,7 @@ public class DocumentMapper implements ToXContent { Collections.reverse(context.docs()); } ParsedDocument doc = new ParsedDocument(context.uid(), context.id(), context.type(), source.routing(), source.timestamp(), source.ttl(), context.docs(), context.analyzer(), - context.source(), context.mappersAdded()).parent(source.parent()); + context.source(), context.mappingsModified()).parent(source.parent()); // reset the context to free up memory context.reset(null, null, null, null); return doc; diff --git a/src/main/java/org/elasticsearch/index/mapper/ParseContext.java b/src/main/java/org/elasticsearch/index/mapper/ParseContext.java index 1f84ecdff3e..d3fa33b0a67 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ParseContext.java +++ b/src/main/java/org/elasticsearch/index/mapper/ParseContext.java @@ -72,7 +72,7 @@ public class ParseContext { private Map ignoredValues = new HashMap(); - private boolean mappersAdded = false; + private boolean mappingsModified = false; private boolean externalValueSet; @@ -103,7 +103,7 @@ public class ParseContext { this.sourceToParse = source; this.source = source == null ? null : sourceToParse.source(); this.path.reset(); - this.mappersAdded = false; + this.mappingsModified = false; this.listener = listener == null ? DocumentMapper.ParseListener.EMPTY : listener; this.allEntries = new AllEntries(); this.ignoredValues.clear(); @@ -117,12 +117,12 @@ public class ParseContext { return this.docMapperParser; } - public boolean mappersAdded() { - return this.mappersAdded; + public boolean mappingsModified() { + return this.mappingsModified; } - public void addedMapper() { - this.mappersAdded = true; + public void setMappingsModified() { + this.mappingsModified = true; } public String index() { diff --git a/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java b/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java index 0abd0b6c4cb..8140835e34a 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java +++ b/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java @@ -49,15 +49,15 @@ public class ParsedDocument { private final BytesReference source; - private boolean mappersAdded; + private boolean mappingsModified; private String parent; - public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, Document document, Analyzer analyzer, BytesReference source, boolean mappersAdded) { - this(uid, id, type, routing, timestamp, ttl, Arrays.asList(document), analyzer, source, mappersAdded); + public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, Document document, Analyzer analyzer, BytesReference source, boolean mappingsModified) { + this(uid, id, type, routing, timestamp, ttl, Arrays.asList(document), analyzer, source, mappingsModified); } - public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, List documents, Analyzer analyzer, BytesReference source, boolean mappersAdded) { + public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, List documents, Analyzer analyzer, BytesReference source, boolean mappingsModified) { this.uid = uid; this.id = id; this.type = type; @@ -67,7 +67,7 @@ public class ParsedDocument { this.documents = documents; this.source = source; this.analyzer = analyzer; - this.mappersAdded = mappersAdded; + this.mappingsModified = mappingsModified; } public String uid() { @@ -120,10 +120,10 @@ public class ParsedDocument { } /** - * Has the parsed document caused for new mappings to be added. + * Has the parsed document caused mappings to be modified? */ - public boolean mappersAdded() { - return mappersAdded; + public boolean mappingsModified() { + return mappingsModified; } public String toString() { diff --git a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java index e4440b0cd38..64fbf67b1fc 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java @@ -521,7 +521,7 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { putMapper(objectMapper); // now re add it context.path().add(currentFieldName); - context.addedMapper(); + context.setMappingsModified(); } } // traverse and parse outside of the mutex @@ -757,7 +757,7 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { } } putMapper(mapper); - context.addedMapper(); + context.setMappingsModified(); } } if (newMapper) { diff --git a/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java b/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java index 158aef6c318..7043c3a0cb1 100644 --- a/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java +++ b/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java @@ -362,7 +362,7 @@ public class PercolatorExecutor extends AbstractIndexComponent { indexCache.clear(searcher.getIndexReader()); } - return new Response(matches, request.doc().mappersAdded()); + return new Response(matches, request.doc().mappingsModified()); } private IndexService percolatorIndexServiceSafe() {