You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "magibney (via GitHub)" <gi...@apache.org> on 2023/02/27 15:19:29 UTC

[GitHub] [solr] magibney commented on a diff in pull request #1378: SOLR-16585: examples test for match all paging

magibney commented on code in PR #1378:
URL: https://github.com/apache/solr/pull/1378#discussion_r1118854120


##########
solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java:
##########
@@ -571,6 +572,68 @@ public void testGetEmptyResults() throws Exception {
     assertEquals(0, out.get(1).size());
   }
 
+  @Test
+  public void testMatchAllPaging() throws Exception {
+    SolrClient client = getSolrClient();
+
+    // Empty the database...
+    client.deleteByQuery("*:*"); // delete everything!
+    if (random().nextBoolean()) {
+      client.commit();
+    }
+    // Add eleven docs
+    List<SolrInputDocument> docs = new ArrayList<>();
+    final int docsTotal = CommonParams.ROWS_DEFAULT + 1;
+    for (int i = 0; i < docsTotal; i++) {
+      SolrInputDocument doc = new SolrInputDocument();
+      doc.addField("id", "id" + i);
+      doc.addField("name", "doc" + i);
+      doc.addField("price", "" + i);
+      docs.add(doc);
+      if (rarely()) {
+        client.add(docs);
+        client.commit();
+        docs.clear();
+      }
+    }
+    client.add(docs);
+    if (random().nextBoolean()) {
+      client.commit();
+    } else {
+      client.optimize();
+    }
+    final List<String> sorts = Arrays.asList("_docid_", "id", "name", "price", null);
+    Collections.shuffle(sorts, random());
+    final List<Integer> starts =
+        Arrays.asList(0, 1, 2, CommonParams.ROWS_DEFAULT, docsTotal, CommonParams.ROWS_DEFAULT + 2);
+    Collections.shuffle(starts, random());
+    for (String sort : sorts.subList(0, 1 + random().nextInt(sorts.size() - 1))) {
+      for (int start : starts.subList(0, 1 + random().nextInt(starts.size() - 1))) {

Review Comment:
   I'm unclear why we're bothering to do subList here? It's not so many combinations that we can't just do all of them (resulting in 30 requests total, right?). Shuffling both is still a good idea (mainly to vary how subsequent requests interact via the queryRestultCache).



##########
solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java:
##########
@@ -571,6 +572,68 @@ public void testGetEmptyResults() throws Exception {
     assertEquals(0, out.get(1).size());
   }
 
+  @Test
+  public void testMatchAllPaging() throws Exception {
+    SolrClient client = getSolrClient();
+
+    // Empty the database...
+    client.deleteByQuery("*:*"); // delete everything!
+    if (random().nextBoolean()) {
+      client.commit();
+    }
+    // Add eleven docs
+    List<SolrInputDocument> docs = new ArrayList<>();
+    final int docsTotal = CommonParams.ROWS_DEFAULT + 1;
+    for (int i = 0; i < docsTotal; i++) {
+      SolrInputDocument doc = new SolrInputDocument();
+      doc.addField("id", "id" + i);
+      doc.addField("name", "doc" + i);
+      doc.addField("price", "" + i);
+      docs.add(doc);
+      if (rarely()) {
+        client.add(docs);
+        client.commit();
+        docs.clear();
+      }
+    }
+    client.add(docs);
+    if (random().nextBoolean()) {
+      client.commit();
+    } else {
+      client.optimize();
+    }
+    final List<String> sorts = Arrays.asList("_docid_", "id", "name", "price", null);
+    Collections.shuffle(sorts, random());
+    final List<Integer> starts =
+        Arrays.asList(0, 1, 2, CommonParams.ROWS_DEFAULT, docsTotal, CommonParams.ROWS_DEFAULT + 2);
+    Collections.shuffle(starts, random());
+    for (String sort : sorts.subList(0, 1 + random().nextInt(sorts.size() - 1))) {
+      for (int start : starts.subList(0, 1 + random().nextInt(starts.size() - 1))) {
+        final SolrQuery query = new SolrQuery("*:*");
+        if (sort != null) {
+          query.setSort(sort, random().nextBoolean() ? SolrQuery.ORDER.asc : SolrQuery.ORDER.desc);
+        }
+        if (start > 0 || random().nextBoolean()) {
+          query.setStart(start);
+        }
+        if (usually()) {
+          query.setRows(CommonParams.ROWS_DEFAULT);
+        }

Review Comment:
   This is ok, but just to point out: issuing a request with rows=ROWS_DEFAULT (either explicit or unset/default) will I think usually cause the docList to be cached in its entirety for the associated sort; so this test will I think largely end up testing queryResultCache?



-- 
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