Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions solr/core/src/java/org/apache/solr/core/SolrCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,11 @@ public static void verbose(Object... args) {
/**
* Get the request handler registered to a given name.
*
* <p>A {@code null} handlerName resolves to the core's default request handler (whichever handler
* is aliased to the empty string, normally the one registered at "/select", or "standard" for
Comment thread
gerlowskija marked this conversation as resolved.
* legacy configs) rather than returning {@code null}; see {@link
* RequestHandlers#initHandlersFromConfig}.
Comment thread
gerlowskija marked this conversation as resolved.
*
* <p>This function is thread safe.
*/
public SolrRequestHandler getRequestHandler(String handlerName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ public void testNotLazyField() throws IOException {

SolrQueryRequest req = req("q", "id:7777", "fl", "id,title,test_hlt");
SolrQueryResponse rsp = new SolrQueryResponse();
core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
core.execute(core.getRequestHandler(null), req, rsp);

DocList dl = ((ResultContext) rsp.getResponse()).getDocList();
Document d = req.getSearcher().getDocFetcher().doc(dl.iterator().nextDoc());
Expand All @@ -786,7 +786,7 @@ public void testLazyField() throws IOException {
// initial request
SolrQueryRequest req = req("q", "id:7777", "fl", "id,title");
SolrQueryResponse rsp = new SolrQueryResponse();
core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
core.execute(core.getRequestHandler(null), req, rsp);

DocList dl = ((ResultContext) rsp.getResponse()).getDocList();
DocIterator di = dl.iterator();
Expand All @@ -808,7 +808,7 @@ public void testLazyField() throws IOException {
// followup request, different fl
req = req("q", "id:7777", "fl", "id,test_hlt");
rsp = new SolrQueryResponse();
core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
core.execute(core.getRequestHandler(null), req, rsp);

dl = ((ResultContext) rsp.getResponse()).getDocList();
di = dl.iterator();
Expand Down
69 changes: 26 additions & 43 deletions solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.solr.common.params.MultiMapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.util.ErrorLogMuter;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -61,63 +60,50 @@ public void testABunchOfConvertedStuff() {
assertU("<commit/>");
assertQ(req("val_s:[a TO z]"), "//*[@numFound='3'] ", "*[count(//doc)=3] ", "//*[@start='0']");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 2, 5, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 2, 5, args));
assertQ(
req,
"//*[@numFound='3'] ",
"*[count(//doc)=1] ",
"*//doc[1]/str[.='pear'] ",
"//*[@start='2']");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 3, 5, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 3, 5, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 4, 5, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 4, 5, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 25, 5, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 25, 5, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 1, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=1] ", "*//doc[1]/str[.='apple']");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 2, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 2, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=2] ", "*//doc[2]/str[.='banana']");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 1, 1, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 1, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=1] ", "*//doc[1]/str[.='banana']");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 3, 1, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 3, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 4, 1, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 4, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 1, 0, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 1, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 0, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
args.put("sort", "val_s1 asc");
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 0, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
args.put("sort", "val_s1 desc");
req =
new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 0, args));
req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
assertQ(req("val_s:[a TO b]"), "//*[@numFound='1']");
assertQ(req("val_s:[a TO cat]"), "//*[@numFound='2']");
Expand Down Expand Up @@ -776,18 +762,18 @@ public void testABunchOfConvertedStuff() {
assertQ(req("id:44"));
args = new HashMap<>();
args.put("fl", "fname_s,arr_f ");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135']");
args = new HashMap<>();
args.put("fl", "fname_s,score");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//str[.='Yonik']", "//float[@name='score' and . > 0]");

// test addition of score field

args = new HashMap<>();
args.put("fl", "score,* ");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(
req,
"//str[.='Yonik'] ",
Expand All @@ -796,7 +782,7 @@ public void testABunchOfConvertedStuff() {
"*[count(//doc/*)>=13]");
args = new HashMap<>();
args.put("fl", "*,score ");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(
req,
"//str[.='Yonik'] ",
Expand All @@ -805,33 +791,33 @@ public void testABunchOfConvertedStuff() {
"*[count(//doc/*)>=13]");
args = new HashMap<>();
args.put("fl", "* ");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135'] ", "*[count(//doc/*)>=12]");

// test maxScore

args = new HashMap<>();
args.put("fl", "score ");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//result[@maxScore>0]");
args = new HashMap<>();
args.put("fl", "score ");
args.put("sort", "id desc");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//result[@maxScore>0]");
args = new HashMap<>();
args.put("fl", "score ");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//@maxScore = //doc/float[@name='score']");
args = new HashMap<>();
args.put("fl", "score ");
args.put("sort", "id desc");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//@maxScore = //doc/float[@name='score']");
args = new HashMap<>();
args.put("fl", "*,score");
args.put("sort", "id desc");
req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 0, args));
req = reqWithPath("/select", makeParams("id:44", 0, 0, args));
assertQ(req, "//result[@maxScore>0]");

// test schema field attribute inheritance and overriding
Expand Down Expand Up @@ -908,18 +894,16 @@ public void testABunchOfConvertedStuff() {

/**
* Utility method to build SolrParams from individual query components. This is a convenience
* method for legacy code that needs to construct params from separate query, qtype, start, limit,
* and additional args.
* method for legacy code that needs to construct params from separate query, start, limit, and
* additional args.
*
* @param query the query string (added as "q" param)
* @param qtype the query type (added as "qt" param)
* @param start the start offset (added as "start" param)
* @param limit the row limit (added as "rows" param)
* @param args additional parameters as a map
* @return SolrParams containing all the specified parameters
*/
public static SolrParams makeParams(
String query, String qtype, int start, int limit, Map<?, ?> args) {
public static SolrParams makeParams(String query, int start, int limit, Map<?, ?> args) {
Map<String, String[]> map = new HashMap<>();
for (Map.Entry<?, ?> e : args.entrySet()) {
String k = e.getKey().toString();
Expand All @@ -928,7 +912,6 @@ public static SolrParams makeParams(
else map.put(k, new String[] {v.toString()});
}
if (query != null) map.put(CommonParams.Q, new String[] {query});
if (qtype != null) map.put(CommonParams.QT, new String[] {qtype});
map.put(CommonParams.START, new String[] {Integer.toString(start)});
map.put(CommonParams.ROWS, new String[] {Integer.toString(limit)});
return new MultiMapSolrParams(map);
Expand Down
3 changes: 1 addition & 2 deletions solr/core/src/test/org/apache/solr/TestGroupingSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,7 @@ public void testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin()
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(request, response));
String handlerName = request.getParams().get(CommonParams.QT);
h.getCore().execute(h.getCore().getRequestHandler(handlerName), request, response);
h.getCore().execute(h.getCore().getRequestHandler(null), request, response);
JavaBinResponseWriter responseWriter = new JavaBinResponseWriter();
responseWriter.write(out, request, response);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ public void doRandomSortsOnLargeIndex() throws Exception {
assertFullWalkNoDupsElevated(
wrapDefaults(
params(
"qt", "/elevate",
"fl", "id,[elevated]",
"forceElevation", "true",
"elevateIds", "50,20,80"),
Expand Down Expand Up @@ -649,8 +648,6 @@ public void doRandomSortsOnLargeIndex() throws Exception {
assertFullWalkNoDupsElevated(
wrapDefaults(
params(
"qt",
"/elevate",
"fl",
fl + ",[elevated]",
// HACK: work around SOLR-15307... same results should match, just not same
Expand Down Expand Up @@ -782,6 +779,7 @@ public SentinelIntSet assertFullWalkNoDupsElevated(
final SentinelIntSet idsElevated = new SentinelIntSet(32, -1);

assertFullWalkNoDups(
"/elevate",
params,
(doc) -> {
final int id = Integer.parseInt(doc.get("id").toString());
Expand Down Expand Up @@ -883,8 +881,16 @@ public SentinelIntSet assertFullWalkNoDups(int maxSize, SolrParams params) throw
*/
public void assertFullWalkNoDups(SolrParams params, Consumer<SolrDocument> consumer)
throws Exception {
assertFullWalkNoDups("/select", params, consumer);
}

/**
* Identical to {@link #assertFullWalkNoDups(SolrParams,Consumer)}, but dispatches the query to
* the specified request handler path.
*/
public void assertFullWalkNoDups(
String requestHandler, SolrParams params, Consumer<SolrDocument> consumer) throws Exception {

final String requestHandler = params.get(CommonParams.QT, "/select");
String cursorMark = CURSOR_MARK_START;
int docsOnThisPage = Integer.MAX_VALUE;
while (0 < docsOnThisPage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.embedded.JettySolrRunner;
import org.apache.solr.util.ServletFixtures;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -351,7 +352,9 @@ void doAddDoc(String id) throws Exception {
}

void doRTG(String ids) throws Exception {
doQuery(ids, "qt", "/get", "ids", ids);
final var expectedIds = StrUtils.splitSmart(ids, ",", true);
final var request = new QueryRequest("/get", params("ids", ids));
doQuery(expectedIds, request);
}

// TODO: refactor some of this stuff into the SolrJ client... it should be easier to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private void assertDocExists(final String clientName, final SolrClient client, f
SolrRequest.METHOD.GET,
"/get",
SolrRequestType.QUERY,
params("qt", "/get", "id", docId, "_trace", clientName, "distrib", "false"))
params("id", docId, "_trace", clientName, "distrib", "false"))
.setRequiresCollection(true))
.process(client, COLLECTION);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.ByteUtils;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
Expand Down Expand Up @@ -72,8 +71,8 @@ public void testUUID() throws Exception {
String s = UUID.randomUUID().toString().toLowerCase(Locale.ROOT);
assertU(adoc("id", "101", "uuid", s));
assertU(commit());
SolrQueryRequestBase req = lrf.makeRequest("q", "*:*");
SolrQueryResponse rsp = h.queryAndResponse(req.getParams().get(CommonParams.QT), req);
SolrQueryRequest req = withPath("/select", lrf.makeRequest("q", "*:*"));
SolrQueryResponse rsp = h.queryAndResponse(req);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
h.getCore().getQueryResponseWriter("javabin").write(baos, req, rsp);
NamedList<?> res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
Expand Down Expand Up @@ -614,7 +613,7 @@ public void testJustJohnJson() throws Exception {
@SuppressWarnings("unchecked")
@Test
public void testJustJohnJavabin() throws Exception {
final SolrQueryRequest johnTwoFL = req(johnAndNancyParams);
final SolrQueryRequest johnTwoFL = reqWithPath("/select", johnAndNancyParams);
ModifiableSolrParams params = new ModifiableSolrParams(johnTwoFL.getParams());
params.set("q", "name_s:john");
params.set("wt", "javabin");
Expand All @@ -626,8 +625,7 @@ public void testJustJohnJavabin() throws Exception {
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(johnTwoFL, rsp));

SolrQueryResponse response =
h.queryAndResponse(johnTwoFL.getParams().get(CommonParams.QT), johnTwoFL);
SolrQueryResponse response = h.queryAndResponse(null, johnTwoFL);
Comment thread
gerlowskija marked this conversation as resolved.

ByteArrayOutputStream bytes = new ByteArrayOutputStream();
johnTwoFL.getResponseWriter().write(bytes, johnTwoFL, response);
Expand Down
5 changes: 3 additions & 2 deletions solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ public void testFacetEnumSearch() throws Exception {
"//*[@name='buckets']/lst[long[@name='count'][.='1']][str[@name='val'][.='High']]");

try (SolrQueryRequest req =
req(
reqWithPath(
"/select",
"fl",
"" + FIELD_NAME,
"q",
Expand All @@ -690,7 +691,7 @@ public void testFacetEnumSearch() throws Exception {
jsonFacetParam,
"wt",
"json")) {
SolrQueryResponse rsp = h.queryAndResponse(req.getParams().get(CommonParams.QT), req);
SolrQueryResponse rsp = h.queryAndResponse(req);
List<NamedList<?>> buckets =
(List<NamedList<?>>)
((NamedList<?>) ((NamedList<?>) rsp.getValues().get("facets")).get("severity"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void beforeTest() throws Exception {

@Test
public void testCacheVetoException() throws Exception {
String url = getSelectUrl("q", "xyz_ignore_exception:solr", "qt", "standard");
Comment thread
gerlowskija marked this conversation as resolved.
String url = getSelectUrl("q", "xyz_ignore_exception:solr");
// We force an exception from Solr. This should emit "no-cache" HTTP headers
ContentResponse response = getHttpClient().GET(url);
assertNotEquals(200, response.getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected String getSelectUrl(String... params) {
sb.append("/select?");

if (params.length == 0) {
sb.append("q=solr&qt=standard");
sb.append("q=solr");
} else {
for (int i = 0; i < params.length / 2; i++) {
if (i > 0) sb.append("&");
Expand Down
Loading
Loading