SOLR-6545: Query field list with wild card on dynamic field fails

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1630169 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-10-08 16:36:03 +00:00
parent aa5227c99f
commit 791ccec5c0
4 changed files with 34 additions and 1 deletions

View File

@ -211,6 +211,9 @@ Bug Fixes
* SOLR-6587: Misleading exception when creating collections in SolrCloud with bad configuration. * SOLR-6587: Misleading exception when creating collections in SolrCloud with bad configuration.
(Tomás Fernández Löbbe) (Tomás Fernández Löbbe)
* SOLR-6545: Query field list with wild card on dynamic field fails.
(Burke Webster, Xu Zhang, shalin)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -804,7 +804,8 @@ public class QueryComponent extends SearchComponent
boolean distribSinglePass = rb.req.getParams().getBool(ShardParams.DISTRIB_SINGLE_PASS, false); boolean distribSinglePass = rb.req.getParams().getBool(ShardParams.DISTRIB_SINGLE_PASS, false);
if(distribSinglePass || (fields != null && fields.wantsField(keyFieldName) if(distribSinglePass || (fields != null && fields.wantsField(keyFieldName)
&& fields.getRequestedFieldNames() != null && Arrays.asList(keyFieldName, "score").containsAll(fields.getRequestedFieldNames()))) { && fields.getRequestedFieldNames() != null
&& (!fields.hasPatternMatching() && Arrays.asList(keyFieldName, "score").containsAll(fields.getRequestedFieldNames())))) {
sreq.purpose |= ShardRequest.PURPOSE_GET_FIELDS; sreq.purpose |= ShardRequest.PURPOSE_GET_FIELDS;
rb.onePassDistributedQuery = true; rb.onePassDistributedQuery = true;
} }

View File

@ -17,6 +17,7 @@
package org.apache.solr; package org.apache.solr;
import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -443,6 +444,16 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
query("q", "id:[1 TO 5]", CommonParams.DEBUG, CommonParams.RESULTS); query("q", "id:[1 TO 5]", CommonParams.DEBUG, CommonParams.RESULTS);
query("q", "id:[1 TO 5]", CommonParams.DEBUG, CommonParams.QUERY); query("q", "id:[1 TO 5]", CommonParams.DEBUG, CommonParams.QUERY);
// SOLR-6545, wild card field list
indexr(id, "19", "text", "d", "cat_a_sS", "1" ,t1, "2");
commit();
rsp = query("q", "id:19", "fl", "id", "fl", "*a_sS");
assertFieldValues(rsp.getResults(), "id", 19);
rsp = query("q", "id:19", "fl", "id," + t1 + ",cat*");
assertFieldValues(rsp.getResults(), "id", 19);
// Check Info is added to for each shard // Check Info is added to for each shard
ModifiableSolrParams q = new ModifiableSolrParams(); ModifiableSolrParams q = new ModifiableSolrParams();
q.set("q", "*:*"); q.set("q", "*:*");

View File

@ -97,6 +97,24 @@ public class DistributedQueryComponentOptimizationTest extends BaseDistributedSe
verifySinglePass("q", "*:*", "fl", "id", "sort", "payload desc", "rows", "20"); // id only is optimized by default verifySinglePass("q", "*:*", "fl", "id", "sort", "payload desc", "rows", "20"); // id only is optimized by default
verifySinglePass("q", "*:*", "fl", "id,score", "sort", "payload desc", "rows", "20"); // id,score only is optimized by default verifySinglePass("q", "*:*", "fl", "id,score", "sort", "payload desc", "rows", "20"); // id,score only is optimized by default
verifySinglePass("q", "*:*", "fl", "score", "sort", "payload asc", "rows", "20", "distrib.singlePass", "true"); verifySinglePass("q", "*:*", "fl", "score", "sort", "payload asc", "rows", "20", "distrib.singlePass", "true");
// SOLR-6545, wild card field list
index(id, "19", "text", "d", "cat_a_sS", "1" ,"dynamic", "2", "payload", ByteBuffer.wrap(new byte[] { (byte)0x80, 0x11, 0x33 }));
commit();
nonDistribRsp = query("q", "id:19", "fl", "id,*a_sS", "sort", "payload asc");
rsp = query("q", "id:19", "fl", "id,*a_sS", "sort", "payload asc", "distrib.singlePass", "true");
assertFieldValues(nonDistribRsp.getResults(), "id", 19);
assertFieldValues(rsp.getResults(), "id", 19);
nonDistribRsp = query("q", "id:19", "fl", "id,dynamic,cat*", "sort", "payload asc");
rsp = query("q", "id:19", "fl", "id,dynamic,cat*", "sort", "payload asc", "distrib.singlePass", "true");
assertFieldValues(nonDistribRsp.getResults(), "id", 19);
assertFieldValues(rsp.getResults(), "id", 19);
verifySinglePass("q", "id:19", "fl", "id,*a_sS", "sort", "payload asc", "distrib.singlePass", "true");
verifySinglePass("q", "id:19", "fl", "id,dynamic,cat*", "sort", "payload asc", "distrib.singlePass", "true");
} }
private void verifySinglePass(String... q) throws SolrServerException { private void verifySinglePass(String... q) throws SolrServerException {