diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5a7732464c7..4e42b531a79 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -211,6 +211,9 @@ Bug Fixes * SOLR-6587: Misleading exception when creating collections in SolrCloud with bad configuration. (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 ---------------------- diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java index cef569f9c13..f30f1a932c4 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java @@ -804,7 +804,8 @@ public class QueryComponent extends SearchComponent boolean distribSinglePass = rb.req.getParams().getBool(ShardParams.DISTRIB_SINGLE_PASS, false); 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; rb.onePassDistributedQuery = true; } diff --git a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java index c43a69035b7..deff80df58f 100644 --- a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java +++ b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java @@ -17,6 +17,7 @@ package org.apache.solr; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; 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.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 ModifiableSolrParams q = new ModifiableSolrParams(); q.set("q", "*:*"); diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java index ee43f991153..b42dd18f342 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java @@ -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,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"); + + // 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 {