_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.
This commit is contained in:
Boaz Leskes 2013-07-02 11:59:14 +02:00
parent 2dcc664310
commit 98bd5a0e66
1 changed files with 2 additions and 3 deletions

View File

@ -22,7 +22,6 @@ package org.elasticsearch.search.fetch;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.ReaderUtil;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.text.StringAndBytesText; import org.elasticsearch.common.text.StringAndBytesText;
import org.elasticsearch.common.text.Text; 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 // go over and extract fields that are not mapped / stored
context.lookup().setNextReader(subReaderContext); context.lookup().setNextReader(subReaderContext);
context.lookup().setNextDocId(subDoc); context.lookup().setNextDocId(subDoc);
if (searchHit.source() != null) { if (fieldsVisitor.source() != null) {
context.lookup().source().setNextSource(new BytesArray(searchHit.source())); context.lookup().source().setNextSource(fieldsVisitor.source());
} }
if (extractFieldNames != null) { if (extractFieldNames != null) {
for (String extractFieldName : extractFieldNames) { for (String extractFieldName : extractFieldNames) {