SOLR-6311: SearchHandler should use path when no qt or shard.qt parameter is specified

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1659694 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy Potter 2015-02-13 21:39:57 +00:00
parent 04e297adee
commit e7ebd44f12
3 changed files with 28 additions and 22 deletions

View File

@ -155,6 +155,10 @@ Other Changes
* SOLR-7103: Remove unused method params in faceting code. (shalin)
* SOLR-6311: When performing distributed queries, SearchHandler should use path
when no qt or shard.qt parameter is specified; fix also resolves SOLR-4479.
(Steve Molloy, Timothy Potter)
================== 5.0.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -18,6 +18,7 @@
package org.apache.solr.handler.component;
import org.apache.lucene.index.ExitableDirectoryReader;
import org.apache.lucene.util.Version;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
@ -306,10 +307,21 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
params.set("NOW", Long.toString(rb.requestInfo.getNOW().getTime()));
}
String shardQt = params.get(ShardParams.SHARDS_QT);
if (shardQt == null) {
params.remove(CommonParams.QT);
} else {
if (shardQt != null) {
params.set(CommonParams.QT, shardQt);
} else {
// for distributed queries that don't include shards.qt, use the original path
// as the default but operators need to update their luceneMatchVersion to enable
// this behavior since it did not work this way prior to 5.1
if (req.getCore().getSolrConfig().luceneMatchVersion.onOrAfter(Version.LUCENE_5_1_0)) {
String reqPath = (String)req.getContext().get("path");
if (!"/select".equals(reqPath)) {
params.set(CommonParams.QT, reqPath);
} // else if path is /select, then the qt gets passed thru if set
} else {
// this is the pre-5.1 behavior, which translates to sending the shard request to /select
params.remove(CommonParams.QT);
}
}
shardHandler1.submit(sreq, shard, params);
}

View File

@ -123,19 +123,16 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
final String tv = "tvrh";
for (String q : new String[] {"id:0", "id:7", "id:[3 TO 6]", "*:*"}) {
query("sort","id desc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true");
// tv.fl diff from fl
query("sort", "id asc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
"fl", "*,score",
"tv.fl", "test_basictv,test_offtv",
TermVectorComponent.COMPONENT_NAME, "true",
@ -144,8 +141,7 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
// multi-valued tv.fl
query("sort", "id asc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
"fl", "*,score",
"tv.fl", "test_basictv",
"tv.fl","test_offtv",
@ -154,16 +150,14 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
// re-use fl glob
query("sort", "id desc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
"fl", "*,score",
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true");
// re-use fl, ignore things we can't handle
query("sort", "id desc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
"fl", "score,test_basictv,[docid],test_postv,val:sum(3,4)",
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true");
@ -171,8 +165,7 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
// re-use (multi-valued) fl, ignore things we can't handle
query("sort", "id desc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
"fl", "score,test_basictv",
"fl", "[docid],test_postv,val:sum(3,4)",
TermVectorComponent.COMPONENT_NAME, "true",
@ -182,8 +175,7 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
query("sort", "id asc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true",
TermVectorParams.DF, "true",
@ -193,8 +185,7 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
query("sort", "id desc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.ALL, "true");
@ -202,8 +193,7 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
query("sort", "id desc",
"qt",tv,
"shards.qt",tv,
"q", q,
"q", q,
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true",
TermVectorParams.DF, "true",