From 98bd5a0e6660d0d473a16c9be19cb8037b905881 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Tue, 2 Jul 2013 11:59:14 +0200 Subject: [PATCH] _source could be loaded twice from disk if only partial_fields was specified or fields needed to be extracted from _source the source it self isn't needed to be returned. --- src/main/java/org/elasticsearch/search/fetch/FetchPhase.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java index 24091919c33..39b69bb3a8f 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java @@ -22,7 +22,6 @@ package org.elasticsearch.search.fetch; import com.google.common.collect.ImmutableMap; import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.ReaderUtil; -import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.text.StringAndBytesText; import org.elasticsearch.common.text.Text; @@ -170,8 +169,8 @@ public class FetchPhase implements SearchPhase { // go over and extract fields that are not mapped / stored context.lookup().setNextReader(subReaderContext); context.lookup().setNextDocId(subDoc); - if (searchHit.source() != null) { - context.lookup().source().setNextSource(new BytesArray(searchHit.source())); + if (fieldsVisitor.source() != null) { + context.lookup().source().setNextSource(fieldsVisitor.source()); } if (extractFieldNames != null) { for (String extractFieldName : extractFieldNames) {