mkhludnev commented on code in PR #2046:
URL: https://github.com/apache/solr/pull/2046#discussion_r1402518124


##########
solr/core/src/test/org/apache/solr/search/stats/TestDistribIDF.java:
##########
@@ -263,4 +267,51 @@ private void addDocsRandomly() throws IOException, 
SolrServerException {
     solrCluster.getSolrClient().commit("collection1_local");
     solrCluster.getSolrClient().commit("collection2_local");
   }
+
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testDisableDistribStats() throws Exception {
+
+    // single collection with implicit router
+    createCollection(COLLECTION, "conf1", ImplicitDocRouter.NAME);
+    SolrClient client = solrCluster.getSolrClient();
+
+    SolrInputDocument doc = new SolrInputDocument();
+    doc.setField("id", "1");
+    doc.setField("cat", "tv");
+    doc.addField(ShardParams._ROUTE_, "a");
+    client.add(COLLECTION, doc);
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "2");
+    doc.setField("cat", "ipad");
+    doc.addField(ShardParams._ROUTE_, "b");
+    client.add(COLLECTION, doc);
+
+    // distributed stats implicitly enabled by default
+    SolrQuery query =
+        new SolrQuery(
+            "q", "*:*",
+            "fl", "id",
+            "fq", "{!terms f=id}1,2",
+            "debug", "track");
+    QueryResponse rsp = client.query(COLLECTION, query);
+    NamedList<Object> track = (NamedList<Object>) 
rsp.getDebugMap().get("track");
+    assertNotNull(track);
+    assertNotNull(track.get("PARSE_QUERY"));
+
+    // distributed stats explicitly disabled
+    query.set(CommonParams.DISABLE_DISTRIB_STATS, "true");
+    rsp = client.query(COLLECTION, query);
+    track = (NamedList<Object>) rsp.getDebugMap().get("track");
+    assertNotNull(track);
+    assertNull(track.get("PARSE_QUERY"));
+
+    // distributed stats explicitly enabled
+    query.set(CommonParams.DISABLE_DISTRIB_STATS, "false");
+    rsp = client.query(COLLECTION, query);
+    track = (NamedList<Object>) rsp.getDebugMap().get("track");
+    assertNotNull(track);
+    assertNotNull(track.get("PARSE_QUERY"));

Review Comment:
   I understand the testing is hard. I barely understand the existing test 
logic. I think, we can figure out how to extend the existing one.



##########
solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java:
##########
@@ -289,6 +289,14 @@ public static EchoParamStyle get(String v) {
   @Deprecated(since = "9.4")
   String DISABLE_REQUEST_ID = "disableRequestId";
 
+  /**
+   * Parameter to disable the distributed term statistics request for current 
query when distributed
+   * IDF is enabled in solrconfig
+   *
+   * <p>Defaults to 'false' if not specified
+   */
+  String DISABLE_DISTRIB_STATS = "disableDistribStats";

Review Comment:
   ~~It's time for bikeshedding~~ Giving the existing parameter 
`distrib.singlePass`, I think we should name it as  `distrib.statsCache=false`. 
Where `statsCache` repeats the tag in solrconfig.xml.   



##########
solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java:
##########
@@ -730,8 +732,11 @@ protected void regularFinishStage(ResponseBuilder rb) {
 
   protected void createDistributedStats(ResponseBuilder rb) {
     StatsCache cache = rb.req.getSearcher().getStatsCache();
-    if ((rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0
-        || rb.getSortSpec().includesScore()) {
+    boolean disableDistribStats =

Review Comment:
   We get the same property twice, I suppose it deserves a getter in 
ResponseBuilder. 



##########
solr/core/src/test/org/apache/solr/search/stats/TestDistribIDF.java:
##########
@@ -263,4 +267,51 @@ private void addDocsRandomly() throws IOException, 
SolrServerException {
     solrCluster.getSolrClient().commit("collection1_local");
     solrCluster.getSolrClient().commit("collection2_local");
   }
+
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testDisableDistribStats() throws Exception {
+
+    // single collection with implicit router
+    createCollection(COLLECTION, "conf1", ImplicitDocRouter.NAME);
+    SolrClient client = solrCluster.getSolrClient();
+
+    SolrInputDocument doc = new SolrInputDocument();
+    doc.setField("id", "1");
+    doc.setField("cat", "tv");
+    doc.addField(ShardParams._ROUTE_, "a");
+    client.add(COLLECTION, doc);
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "2");
+    doc.setField("cat", "ipad");
+    doc.addField(ShardParams._ROUTE_, "b");
+    client.add(COLLECTION, doc);

Review Comment:
   it doesn't even commit. Right?  



-- 
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-unsubscr...@solr.apache.org

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


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

Reply via email to