Skip to content
Permalink
Browse files

Publish ObjectMappers once the entire document has been parsed.

If we publish the object mappers before we updated the actual DocumentFieldMappers
concurrently indexing documents can suddenly use default analysis chains since they skip
application of dynamic template or dynamic mappers in general since if there is a race condition
ObjectMappers are only build once.

Closes elastic#3544
  • Loading branch information...
s1monw committed Aug 26, 2013
1 parent b329943 commit f2dec2c53f560649d5a456154c9992b03ad9eb94
@@ -461,6 +461,7 @@ public ParsedDocument parse(SourceToParse source, @Nullable ParseListener listen
source.type(this.type);

XContentParser parser = source.parser();
boolean success = false;
try {
if (parser == null) {
parser = XContentHelper.createParser(source.source());
@@ -529,6 +530,7 @@ public ParsedDocument parse(SourceToParse source, @Nullable ParseListener listen
for (RootMapper rootMapper : rootMappersOrdered) {
rootMapper.validate(context);
}
success = true;
} catch (Throwable e) {
// we have to fire up any new mappers even on a failure, because they
// have been added internally to each compound mapper...
@@ -554,10 +556,12 @@ public ParsedDocument parse(SourceToParse source, @Nullable ParseListener listen

throw new MapperParsingException("failed to parse", e);
} finally {
rootObjectMapper.finishParse(context, success);
// only close the parser when its not provided externally
if (source.parser() == null && parser != null) {
parser.close();
}

}
// reverse the order of docs for nested docs support, parent should be last
if (context.docs().size() > 1) {
Oops, something went wrong.

0 comments on commit f2dec2c

Please sign in to comment.
You can’t perform that action at this time.