From c7d58816864d44c2514a306b059ae95601c1eeac Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Wed, 7 Aug 2013 23:27:17 +0200 Subject: [PATCH] make sure we add the _uid as the first field in a doc this will improve early termination loading times, but requires potential improvements in Lucene in terms of decompression --- .../java/org/elasticsearch/index/mapper/DocumentMapper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java index 7d0194f602a..cf53473f68f 100644 --- a/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java @@ -162,7 +162,10 @@ public class DocumentMapper implements ToXContent { idFieldMapper = new IdFieldMapper(fieldType); } } + // UID first so it will be the first stored field to load (so will benefit from "fields: []" early termination + this.rootMappers.put(UidFieldMapper.class, new UidFieldMapper()); this.rootMappers.put(IdFieldMapper.class, idFieldMapper); + this.rootMappers.put(RoutingFieldMapper.class, new RoutingFieldMapper()); // add default mappers, order is important (for example analyzer should come before the rest to set context.analyzer) this.rootMappers.put(SizeFieldMapper.class, new SizeFieldMapper()); this.rootMappers.put(IndexFieldMapper.class, new IndexFieldMapper()); @@ -171,10 +174,8 @@ public class DocumentMapper implements ToXContent { this.rootMappers.put(AnalyzerMapper.class, new AnalyzerMapper()); this.rootMappers.put(AllFieldMapper.class, new AllFieldMapper()); this.rootMappers.put(BoostFieldMapper.class, new BoostFieldMapper()); - this.rootMappers.put(RoutingFieldMapper.class, new RoutingFieldMapper()); this.rootMappers.put(TimestampFieldMapper.class, new TimestampFieldMapper()); this.rootMappers.put(TTLFieldMapper.class, new TTLFieldMapper()); - this.rootMappers.put(UidFieldMapper.class, new UidFieldMapper()); // don't add parent field, by default its "null" }