dsmiley commented on code in PR #4149:
URL: https://github.com/apache/solr/pull/4149#discussion_r3025301863


##########
solr/solrj/src/java/org/apache/solr/client/solrj/response/LukeResponse.java:
##########
@@ -113,11 +115,12 @@ public static class FieldInfo implements Serializable {
     String name;
     String type;
     String schema;
-    int docs;
+    long docs;
     int distinct;
     EnumSet<FieldFlag> flags;
     boolean cacheableFaceting;
     NamedList<Integer> topTerms;
+    Map<String, Object> extras = new HashMap<>();

Review Comment:
   maybe use TreeMap for consistent ordering?



##########
solr/solrj/src/java/org/apache/solr/client/solrj/response/LukeResponse.java:
##########
@@ -256,16 +277,25 @@ public String getIndexDirectory() {
     return (String) indexInfo.get("directory");
   }
 
-  public Integer getNumDocs() {
+  private Long getIndexLong(String key) {

Review Comment:
   the word "Index" here confuses me.  



##########
solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerDistribTest.java:
##########
@@ -0,0 +1,522 @@
+/*
+ * 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.handler.admin;
+
+import java.util.Map;
+import org.apache.solr.BaseDistributedSearchTestCase;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.response.InputStreamResponseParser;
+import org.apache.solr.client.solrj.response.LukeResponse;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.util.BaseTestHarness;
+import org.junit.Test;
+
+public class LukeRequestHandlerDistribTest extends 
BaseDistributedSearchTestCase {
+
+  private static final Long NUM_DOCS = 20L;
+
+  public LukeRequestHandlerDistribTest() {
+    fixShardCount(2);
+  }
+
+  private LukeResponse requestLuke() throws Exception {
+    return requestLuke(new ModifiableSolrParams());
+  }
+
+  private LukeResponse requestLuke(ModifiableSolrParams extra) throws 
Exception {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("qt", "/admin/luke");
+    params.set("numTerms", "0");
+    params.add(extra);
+
+    // query() sends to control and a random shard with shards param, compares 
responses
+    handle.put("QTime", SKIPVAL);
+    handle.put("index", SKIP);
+    handle.put("shards", SKIP);
+    // Detailed per-field stats (distinct, topTerms, histogram) are kept 
per-shard in
+    // distributed mode and intentionally excluded from the aggregated 
top-level fields.
+    // Local mode includes them inline, so skip them in the comparison.
+    handle.put("distinct", SKIP);
+    handle.put("topTerms", SKIP);
+    handle.put("histogram", SKIP);
+    QueryResponse qr = query(params);
+    LukeResponse rsp = new LukeResponse();
+    rsp.setResponse(qr.getResponse());
+
+    return rsp;
+  }
+
+  private void assertLukeXPath(ModifiableSolrParams extra, String... xpaths) 
throws Exception {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("qt", "/admin/luke");
+    params.set("numTerms", "0");
+    params.set("wt", "xml");
+    params.set("shards", shards);
+    params.add(extra);
+    QueryRequest req = new QueryRequest(params);
+    req.setResponseParser(new InputStreamResponseParser("xml"));
+    NamedList<Object> raw = controlClient.request(req);
+    String xml = InputStreamResponseParser.consumeResponseToString(raw);
+    String failedXpath = BaseTestHarness.validateXPath(xml, xpaths);
+    assertNull("XPath validation failed: " + failedXpath + "\nResponse:\n" + 
xml, failedXpath);
+  }
+
+  private void indexTestData() throws Exception {
+    for (int i = 0; i < NUM_DOCS; i++) {
+      index("id", String.valueOf(i), "name", "name_" + i, "subject", "subject 
value " + (i % 5));
+    }
+    commit();
+  }
+
+  @Test
+  @ShardsFixed(num = 2)
+  public void testDistributedAggregate() throws Exception {
+    indexTestData();
+
+    LukeResponse rsp = requestLuke();
+
+    assertEquals("aggregated numDocs should equal total docs", NUM_DOCS, 
rsp.getNumDocs());
+    assertTrue("aggregated maxDoc should be > 0", rsp.getMaxDoc() > 0);
+    assertNotNull("deletedDocs should be present", rsp.getDeletedDocs());
+
+    Map<String, LukeResponse> shardResponses = rsp.getShardResponses();

Review Comment:
   I kind of question, do we want the distributed search to have shard 
information?  Naturally we want the merged information.  Have you considered 
use of org.apache.solr.common.params.ShardParams#SHARDS_INFO to toggle this?



##########
solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerDistribTest.java:
##########
@@ -0,0 +1,522 @@
+/*
+ * 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.handler.admin;
+
+import java.util.Map;
+import org.apache.solr.BaseDistributedSearchTestCase;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.response.InputStreamResponseParser;
+import org.apache.solr.client.solrj.response.LukeResponse;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.util.BaseTestHarness;
+import org.junit.Test;
+
+public class LukeRequestHandlerDistribTest extends 
BaseDistributedSearchTestCase {
+
+  private static final Long NUM_DOCS = 20L;
+
+  public LukeRequestHandlerDistribTest() {
+    fixShardCount(2);
+  }
+
+  private LukeResponse requestLuke() throws Exception {
+    return requestLuke(new ModifiableSolrParams());
+  }
+
+  private LukeResponse requestLuke(ModifiableSolrParams extra) throws 
Exception {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("qt", "/admin/luke");
+    params.set("numTerms", "0");
+    params.add(extra);
+
+    // query() sends to control and a random shard with shards param, compares 
responses
+    handle.put("QTime", SKIPVAL);
+    handle.put("index", SKIP);
+    handle.put("shards", SKIP);
+    // Detailed per-field stats (distinct, topTerms, histogram) are kept 
per-shard in
+    // distributed mode and intentionally excluded from the aggregated 
top-level fields.
+    // Local mode includes them inline, so skip them in the comparison.
+    handle.put("distinct", SKIP);
+    handle.put("topTerms", SKIP);
+    handle.put("histogram", SKIP);
+    QueryResponse qr = query(params);
+    LukeResponse rsp = new LukeResponse();
+    rsp.setResponse(qr.getResponse());
+
+    return rsp;
+  }
+
+  private void assertLukeXPath(ModifiableSolrParams extra, String... xpaths) 
throws Exception {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("qt", "/admin/luke");
+    params.set("numTerms", "0");
+    params.set("wt", "xml");
+    params.set("shards", shards);
+    params.add(extra);
+    QueryRequest req = new QueryRequest(params);

Review Comment:
   lets use GenericRequest as you aren't using SearchHandler



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to