SOLR-5968: BinaryResponseWriter fetches unnecessary stored fields when only pseudo-fields are requested

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1612200 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-07-21 07:25:24 +00:00
parent 2bf04d0308
commit 27d68500ee
2 changed files with 16 additions and 4 deletions

View File

@ -215,6 +215,9 @@ Optimizations
DocumentBuilder.toDocument for use-cases with large number of fields and copyFields.
(Steven Bower via shalin)
* SOLR-5968: BinaryResponseWriter fetches unnecessary stored fields when only pseudo-fields
are requested. (Gregg Donovan via shalin)
Other Changes
---------------------

View File

@ -34,6 +34,7 @@ import org.apache.solr.schema.*;
import org.apache.solr.search.DocList;
import org.apache.solr.search.ReturnFields;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.search.SolrReturnFields;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -141,11 +142,19 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
}
Set<String> fnames = returnFields.getLuceneFieldNames();
boolean onlyPseudoFields = (fnames == null && !returnFields.wantsAllFields())
|| (fnames != null && fnames.size() == 1 && SolrReturnFields.SCORE.equals(fnames.iterator().next()));
context.iterator = ids.iterator();
for (int i = 0; i < sz; i++) {
int id = context.iterator.nextDoc();
SolrDocument sdoc;
if (onlyPseudoFields) {
// no need to get stored fields of the document, see SOLR-5968
sdoc = new SolrDocument();
} else {
StoredDocument doc = searcher.doc(id, fnames);
SolrDocument sdoc = getDoc(doc);
sdoc = getDoc(doc);
}
if( transformer != null ) {
transformer.transform(sdoc, id);
}