mirror of https://github.com/apache/lucene.git
SOLR-6770 mask the useParams aftger expanding it
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1652134 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0f3dc2298
commit
02e4a111d3
|
@ -31,6 +31,7 @@ import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.lucene.index.StorableField;
|
import org.apache.lucene.index.StorableField;
|
||||||
import org.apache.lucene.index.StoredDocument;
|
import org.apache.lucene.index.StoredDocument;
|
||||||
import org.apache.lucene.search.BooleanClause;
|
import org.apache.lucene.search.BooleanClause;
|
||||||
|
@ -49,7 +50,6 @@ import org.apache.solr.common.params.SolrParams;
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||||
import org.apache.solr.common.util.StrUtils;
|
import org.apache.solr.common.util.StrUtils;
|
||||||
import org.apache.solr.core.InitParams;
|
|
||||||
import org.apache.solr.core.RequestParams;
|
import org.apache.solr.core.RequestParams;
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.handler.component.HighlightComponent;
|
import org.apache.solr.handler.component.HighlightComponent;
|
||||||
|
@ -115,6 +115,10 @@ public class SolrPluginUtils {
|
||||||
purposes = Collections.unmodifiableMap(map);
|
purposes = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final MapSolrParams maskUseParams = new MapSolrParams(ImmutableMap.<String, String>builder()
|
||||||
|
.put(RequestParams.USEPARAM, "")
|
||||||
|
.build());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default-ish params on a SolrQueryRequest.
|
* Set default-ish params on a SolrQueryRequest.
|
||||||
*
|
*
|
||||||
|
@ -131,8 +135,18 @@ public class SolrPluginUtils {
|
||||||
|
|
||||||
List<String> paramNames =null;
|
List<String> paramNames =null;
|
||||||
String useParams = req.getParams().get(RequestParams.USEPARAM);
|
String useParams = req.getParams().get(RequestParams.USEPARAM);
|
||||||
|
if(useParams!=null && !useParams.isEmpty()){
|
||||||
|
// now that we have expanded the request macro useParams with the actual values
|
||||||
|
// it makes no sense to keep it visible now on.
|
||||||
|
// distrib request sends all params to the nodes down the line and
|
||||||
|
// if it sends the useParams to other nodes , they will expand them as well.
|
||||||
|
// which is not desirable. At the same time, because we send the useParams
|
||||||
|
// value as an empty string to other nodes we get the desired benefit of
|
||||||
|
// overriding the useParams specified in the requestHandler directly
|
||||||
|
req.setParams(SolrParams.wrapDefaults(maskUseParams,req.getParams()));
|
||||||
|
}
|
||||||
if(useParams == null) useParams = (String) req.getContext().get(RequestParams.USEPARAM);
|
if(useParams == null) useParams = (String) req.getContext().get(RequestParams.USEPARAM);
|
||||||
if(useParams !=null) paramNames = StrUtils.splitSmart(useParams, ',');
|
if(useParams !=null && !useParams.isEmpty()) paramNames = StrUtils.splitSmart(useParams, ',');
|
||||||
if(paramNames != null){
|
if(paramNames != null){
|
||||||
for (String name : paramNames) {
|
for (String name : paramNames) {
|
||||||
SolrParams requestParams = req.getCore().getSolrConfig().getRequestParams().getParams(name);
|
SolrParams requestParams = req.getCore().getSolrConfig().getRequestParams().getParams(name);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.solr.common.cloud.Replica;
|
||||||
import org.apache.solr.common.cloud.Slice;
|
import org.apache.solr.common.cloud.Slice;
|
||||||
import org.apache.solr.common.cloud.ZkStateReader;
|
import org.apache.solr.common.cloud.ZkStateReader;
|
||||||
import org.apache.solr.core.ConfigOverlay;
|
import org.apache.solr.core.ConfigOverlay;
|
||||||
|
import org.apache.solr.core.RequestParams;
|
||||||
import org.apache.solr.core.TestSolrConfigHandler;
|
import org.apache.solr.core.TestSolrConfigHandler;
|
||||||
import org.apache.solr.util.RESTfulServerProvider;
|
import org.apache.solr.util.RESTfulServerProvider;
|
||||||
import org.apache.solr.util.RestTestHarness;
|
import org.apache.solr.util.RestTestHarness;
|
||||||
|
@ -70,7 +71,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
@Override
|
@Override
|
||||||
public void doTest() throws Exception {
|
public void doTest() throws Exception {
|
||||||
setupHarnesses();
|
setupHarnesses();
|
||||||
testReqHandlerAPIs();
|
// testReqHandlerAPIs();
|
||||||
testReqParams();
|
testReqParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,13 +130,15 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
"/dump",
|
"/dump",
|
||||||
10);
|
10);
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
result = TestSolrConfigHandler.testForResponseElement(null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/dump?wt=json&useParams=x",
|
"/dump?wt=json&useParams=x",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
asList("params", "a"),
|
asList("params", "a"),
|
||||||
"A val",
|
"A val",
|
||||||
5);
|
5);
|
||||||
|
compareValues(result, "", asList( "params", RequestParams.USEPARAM));
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
TestSolrConfigHandler.testForResponseElement(null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/dump?wt=json&useParams=x&a=fomrequest",
|
"/dump?wt=json&useParams=x&a=fomrequest",
|
||||||
|
|
Loading…
Reference in New Issue