You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by jb...@apache.org on 2023/09/15 18:00:43 UTC
[solr] branch SOLR-16931 created (now 48100b53869)
This is an automated email from the ASF dual-hosted git repository.
jbernste pushed a change to branch SOLR-16931
in repository https://gitbox.apache.org/repos/asf/solr.git
at 48100b53869 Add distributed test case
This branch includes the following new commits:
new 48100b53869 Add distributed test case
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[solr] 01/01: Add distributed test case
Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jbernste pushed a commit to branch SOLR-16931
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 48100b53869016c4eef8b88b29bc60f450303257
Author: Joel Bernstein <jb...@apache.org>
AuthorDate: Fri Sep 15 14:00:07 2023 -0400
Add distributed test case
---
.../solr/search/DistributedReRankExplainTest.java | 97 ++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/solr/core/src/test/org/apache/solr/search/DistributedReRankExplainTest.java b/solr/core/src/test/org/apache/solr/search/DistributedReRankExplainTest.java
new file mode 100644
index 00000000000..434375844b6
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/search/DistributedReRankExplainTest.java
@@ -0,0 +1,97 @@
+package org.apache.solr.search;
+
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.SolrCloudTestCase;
+
+import org.apache.solr.cluster.Cluster;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.util.RTimerTree;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.*;
+import java.lang.invoke.MethodHandles;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.Principal;
+import java.util.*;
+
+import org.apache.solr.SolrTestCaseJ4;
+
+
+@SolrTestCaseJ4.SuppressSSL
+public class DistributedReRankExplainTest extends SolrCloudTestCase {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private static final int numShards = 2;
+ private static final String COLLECTIONORALIAS = "collection1";
+
+ private static final int TIMEOUT = DEFAULT_TIMEOUT;
+ private static final String id = "id";
+
+ private static boolean useAlias;
+
+ @BeforeClass
+ public static void setupCluster() throws Exception {
+ System.setProperty("managed.schema.mutable", "true");
+ String collection = COLLECTIONORALIAS;
+ configureCluster(2)
+ .addConfig(
+ "conf1", TEST_PATH().resolve("configsets").resolve("cloud-managed").resolve("conf"))
+ .configure();
+ CollectionAdminRequest.createCollection(collection, "conf1", 2, 1)
+ .setPerReplicaState(SolrCloudTestCase.USE_PER_REPLICA_STATE)
+ .process(cluster.getSolrClient());
+
+ cluster.waitForActiveCollection(collection, 2, 2);
+ }
+
+ @Test
+ public void testReRankExplain() throws Exception {
+ CloudSolrClient client = cluster.getSolrClient();
+ UpdateRequest updateRequest = new UpdateRequest();
+ for(int i=0; i<100; i++) {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField(CommonParams.ID, Integer.toString(i));
+ doc.addField("test_s", "hello");
+ updateRequest.add(doc);
+ }
+ updateRequest.process(client, COLLECTIONORALIAS);
+ client.commit(COLLECTIONORALIAS);
+
+ ModifiableSolrParams solrParams = new ModifiableSolrParams();
+ String reRank = "{!rerank reRankDocs=10 reRankMainScale=0-10 reRankQuery='test_s:hello'}";
+ solrParams.add("q", "test_s:hello").add("debugQuery", "true").add(CommonParams.RQ, reRank);
+ QueryRequest queryRequest = new QueryRequest(solrParams);
+ QueryResponse queryResponse = queryRequest.process(client, COLLECTIONORALIAS);
+ Map<String, Object> debug = queryResponse.getDebugMap();
+ assertNotNull(debug);
+ String explain = debug.get("explain").toString();
+ assertTrue(explain.contains("5.0101576 = combined scaled first and unscaled second pass score "));
+
+ solrParams = new ModifiableSolrParams();
+ reRank = "{!rerank reRankDocs=10 reRankScale=0-10 reRankQuery='test_s:hello'}";
+ solrParams.add("q", "test_s:hello").add("debug", "true").add(CommonParams.RQ, reRank);
+ queryRequest = new QueryRequest(solrParams);
+ queryResponse = queryRequest.process(client, COLLECTIONORALIAS);
+ debug = queryResponse.getDebugMap();
+ assertNotNull(debug);
+ explain = debug.get("explain").toString();
+ assertTrue(explain.contains("10.005078 = combined unscaled first and scaled second pass score "));
+ }
+
+}
\ No newline at end of file