You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/11/09 02:13:36 UTC

[GitHub] [solr] risdenk commented on a diff in pull request #1154: SOLR-16496: provide option for Query Elevation Component to bypass filters

risdenk commented on code in PR #1154:
URL: https://github.com/apache/solr/pull/1154#discussion_r1017332836


##########
solr/core/src/test/org/apache/solr/search/QueryUtilsTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.search;
+
+import java.util.ArrayList;
+import java.util.Set;
+import org.apache.lucene.search.Query;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.handler.component.QueryComponent;
+import org.apache.solr.handler.component.ResponseBuilder;
+import org.apache.solr.handler.component.SearchComponent;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Test;
+
+/** Tests the utility methods in QueryUtils. */
+public class QueryUtilsTest extends SolrTestCaseJ4 {
+
+  @Test
+  public void testGetTaggedQueries() throws Exception {
+    try {
+      initCore("solrconfig.xml", "schema.xml");
+
+      SearchComponent queryComponent =
+          h.getCore().getSearchComponent(QueryComponent.COMPONENT_NAME);
+
+      // first make sure QueryUtils.getTaggedQueries() behaves properly on an "empty" request
+      try (SolrQueryRequest request = req()) {
+        ResponseBuilder rb =
+            new ResponseBuilder(request, new SolrQueryResponse(), new ArrayList<>());
+        assertEquals(0, QueryUtils.getTaggedQueries(request, Set.of("t0")).size());
+        queryComponent.prepare(rb);
+        assertEquals(0, QueryUtils.getTaggedQueries(request, Set.of("t0")).size());
+      }
+
+      // now test with a request that includes multiple tagged queries
+      try (SolrQueryRequest request =
+          req(
+              CommonParams.Q, "{!tag=t0}text:zzzz",
+              CommonParams.FQ, "{!tag=t1,t2}str_s:a",
+              CommonParams.FQ, "{!tag=t3}str_s:b",
+              CommonParams.FQ, "{!tag=t3}str_s:b",
+              CommonParams.FQ, "{!tag=t4}str_s:b",
+              CommonParams.FQ, "str_s:b",
+              CommonParams.FQ, "str_s:c")) {
+
+        ResponseBuilder rb =
+            new ResponseBuilder(request, new SolrQueryResponse(), new ArrayList<>());
+
+        // the "tag map" will not be populated in the SolrQueryRequest's "context" until
+        // the QParsers have been initialized; before such time, QueryUtils.getTaggedQueries will
+        // always return
+        // an empty set

Review Comment:
   make the comment a single line. then run `./gradlew tidy` it will automatically break the comment across lines. you can do this for any longer length comment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org