SOLR-3214: If you use multiple fl entries rather than a comma separated list, all but the first entry can be ignored if you are using distributed search.

SOLR-3256: Distributed search throws NPE when using fl=score

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1305927 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-03-27 17:41:18 +00:00
parent 46724924e4
commit 7b3f632f32
3 changed files with 22 additions and 13 deletions

View File

@ -1,4 +1,4 @@
 Apache Solr Release Notes  Apache Solr Release Notes
Introduction Introduction
------------ ------------
@ -353,7 +353,9 @@ Bug Fixes
* SOLR-3062: A join in the main query was not respecting any filters pushed * SOLR-3062: A join in the main query was not respecting any filters pushed
down to it via acceptDocs since LUCENE-1536. (Mike Hugo, yonik) down to it via acceptDocs since LUCENE-1536. (Mike Hugo, yonik)
* SOLR-3214: If you use multiple fl entries rather than a comma separated list, all but the first
entry can be ignored if you are using distributed search. (Tomas Fernandez Lobbe via Mark Miller)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -941,17 +941,10 @@ public class QueryComponent extends SearchComponent
// we already have the field sort values // we already have the field sort values
sreq.params.remove(ResponseBuilder.FIELD_SORT_VALUES); sreq.params.remove(ResponseBuilder.FIELD_SORT_VALUES);
// make sure that the id is returned for correlation. if(!rb.rsp.getReturnFields().wantsField(uniqueField.getName())) {
String fl = sreq.params.get(CommonParams.FL); sreq.params.add(CommonParams.FL, uniqueField.getName());
if (fl != null) { }
fl = fl.trim();
// currently, "score" is synonymous with "*,score" so
// don't add "id" if the fl is empty or "score" or it would change the meaning.
if (fl.length()!=0 && !"score".equals(fl) && !"*".equals(fl)) {
sreq.params.set(CommonParams.FL, fl+','+uniqueField.getName());
}
}
ArrayList<String> ids = new ArrayList<String>(shardDocs.size()); ArrayList<String> ids = new ArrayList<String>(shardDocs.size());
for (ShardDoc shardDoc : shardDocs) { for (ShardDoc shardDoc : shardDocs) {
// TODO: depending on the type, we may need more tha a simple toString()? // TODO: depending on the type, we may need more tha a simple toString()?
@ -979,6 +972,7 @@ public class QueryComponent extends SearchComponent
SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response"); SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response");
String keyFieldName = rb.req.getSchema().getUniqueKeyField().getName(); String keyFieldName = rb.req.getSchema().getUniqueKeyField().getName();
boolean removeKeyField = !rb.rsp.getReturnFields().wantsField(keyFieldName);
for (SolrDocument doc : docs) { for (SolrDocument doc : docs) {
Object id = doc.getFieldValue(keyFieldName); Object id = doc.getFieldValue(keyFieldName);
@ -987,6 +981,9 @@ public class QueryComponent extends SearchComponent
if (returnScores && sdoc.score != null) { if (returnScores && sdoc.score != null) {
doc.setField("score", sdoc.score); doc.setField("score", sdoc.score);
} }
if(removeKeyField) {
doc.removeFields(keyFieldName);
}
rb._responseDocs.set(sdoc.positionInResponse, doc); rb._responseDocs.set(sdoc.positionInResponse, doc);
} }
} }

View File

@ -204,6 +204,16 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
"facet.range.start",200, "facet.range.start",200,
"facet.range.gap",100, "facet.range.gap",100,
"f."+tlong+".facet.range.end",900); "f."+tlong+".facet.range.end",900);
// variations of fl
query("q","*:*", "fl","score","sort",i1 + " desc");
query("q","*:*", "fl",i1 + ",score","sort",i1 + " desc");
query("q","*:*", "fl", i1, "fl","score","sort",i1 + " desc");
query("q","*:*", "fl", "id," + i1,"sort",i1 + " desc");
query("q","*:*", "fl", "id", "fl",i1,"sort",i1 + " desc");
query("q","*:*", "fl",i1, "fl", "id","sort",i1 + " desc");
query("q","*:*", "fl", "id", "fl",nint, "fl",tint,"sort",i1 + " desc");
query("q","*:*", "fl",nint, "fl", "id", "fl",tint,"sort",i1 + " desc");
stress=0; // turn off stress... we want to tex max combos in min time stress=0; // turn off stress... we want to tex max combos in min time
for (int i=0; i<25*RANDOM_MULTIPLIER; i++) { for (int i=0; i<25*RANDOM_MULTIPLIER; i++) {