This is an automated email from the ASF dual-hosted git repository.

daim pushed a commit to branch OAK-10199
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit f433d4c0cf77391bbea8211f74f73e1ab0daddd0
Author: Fabrizio Fortino <[email protected]>
AuthorDate: Fri Apr 21 11:28:22 2023 +0200

    OAK-10202: change default fetch size to match lucene behaviour (#907)
    
    * OAK-10202: change default fetch size to match lucene behaviour
    
    * OAK-10202: consolidate usage of java 9/10 immutable data structures
---
 .../index/elastic/ElasticIndexDefinition.java      |  2 +-
 .../plugins/index/elastic/ElasticContentTest.java  | 37 +++++++++++++++++-----
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git 
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java
 
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java
index 15b2773a4d..31b82d29e7 100644
--- 
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java
+++ 
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java
@@ -63,7 +63,7 @@ public class ElasticIndexDefinition extends IndexDefinition {
     public static final int NUMBER_OF_REPLICAS_DEFAULT = 1;
 
     public static final String QUERY_FETCH_SIZES = "queryFetchSizes";
-    public static final Long[] QUERY_FETCH_SIZES_DEFAULT = new Long[]{100L, 
1000L};
+    public static final Long[] QUERY_FETCH_SIZES_DEFAULT = new Long[]{10L, 
100L, 1000L};
 
     public static final String TRACK_TOTAL_HITS = "trackTotalHits";
     public static final Integer TRACK_TOTAL_HITS_DEFAULT = 10000;
diff --git 
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticContentTest.java
 
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticContentTest.java
index ef70ad99ed..60e757389d 100644
--- 
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticContentTest.java
+++ 
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticContentTest.java
@@ -23,9 +23,8 @@ import org.apache.jackrabbit.oak.stats.StatisticsProvider;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Random;
 import java.util.UUID;
 import java.util.function.BiConsumer;
@@ -171,6 +170,28 @@ public class ElasticContentTest extends 
ElasticAbstractQueryTest {
         assertEventually(() -> assertThat(countDocuments(index), equalTo(1L)));
     }
 
+    @Test
+    public void indexWithDefaultFetchSizes() throws Exception {
+        IndexDefinitionBuilder builder = createIndex("a").noAsync();
+        builder.indexRule("nt:base").property("a").propertyIndex();
+        setIndex(UUID.randomUUID().toString(), builder);
+        root.commit();
+
+        Tree content = root.getTree("/").addChild("content");
+        IntStream.range(0, 20).forEach(n -> {
+                    Tree child = content.addChild("child_" + n);
+                    child.setProperty("a", "text");
+                }
+        );
+        root.commit(Map.of("sync-mode", "rt"));
+
+        List<String> results = IntStream.range(0, 20).mapToObj(i -> 
"/content/child_" + i).collect(Collectors.toList());
+
+        reset(spyMetricHandler);
+        assertQuery("select [jcr:path] from [nt:base] where [a] = 'text'", 
results);
+        verify(spyMetricHandler, times(2)).markQuery(anyString(), 
anyBoolean());
+    }
+
     @Test
     public void indexWithCustomFetchSizes() throws Exception {
         BiConsumer<String, Iterable<Long>> buildIndex = (p, fetchSizes) -> {
@@ -180,9 +201,9 @@ public class ElasticContentTest extends 
ElasticAbstractQueryTest {
             setIndex(p + "_" + UUID.randomUUID(), builder);
         };
 
-        buildIndex.accept("a", Collections.singletonList(1L));
-        buildIndex.accept("b", Arrays.asList(1L, 2L));
-        buildIndex.accept("c", Arrays.asList(3L, 100L));
+        buildIndex.accept("a", List.of(1L));
+        buildIndex.accept("b", List.of(1L, 2L));
+        buildIndex.accept("c", List.of(3L, 100L));
         root.commit();
 
         Tree content = root.getTree("/").addChild("content");
@@ -193,9 +214,9 @@ public class ElasticContentTest extends 
ElasticAbstractQueryTest {
                     child.setProperty("c", "text");
                 }
         );
-        root.commit(Collections.singletonMap("sync-mode", "rt"));
+        root.commit(Map.of("sync-mode", "rt"));
 
-        List<String> results = Arrays.asList("/content/child_0", 
"/content/child_1", "/content/child_2");
+        List<String> results = IntStream.range(0, 3).mapToObj(i -> 
"/content/child_" + i).collect(Collectors.toList());
 
         reset(spyMetricHandler);
         assertQuery("select [jcr:path] from [nt:base] where [a] = 'text'", 
results);
@@ -220,7 +241,7 @@ public class ElasticContentTest extends 
ElasticAbstractQueryTest {
             setIndex(p + "_" + UUID.randomUUID(), builder);
         };
 
-        buildIndex.accept("a", Collections.singletonList(10L));
+        buildIndex.accept("a", List.of(10L));
         root.commit();
 
         Tree content = root.getTree("/").addChild("content");

Reply via email to