@@ -1709,6 +1709,44 @@ public <T> T mapSearchHit(SearchHit searchHit, Class<T> type) {
1709
1709
elasticsearchTemplate .clearScroll (scroll .getScrollId ());
1710
1710
}
1711
1711
1712
+ @ Test // DATAES-671
1713
+ public void shouldPassIndicesOptionsForGivenSearchScrollQuery () {
1714
+
1715
+ // given
1716
+ long scrollTimeInMillis = 3000 ;
1717
+ String documentId = randomNumeric (5 );
1718
+ SampleEntity sampleEntity = SampleEntity .builder ().id (documentId ).message ("some message" )
1719
+ .version (System .currentTimeMillis ()).build ();
1720
+
1721
+ IndexQuery idxQuery = new IndexQueryBuilder ().withIndexName (INDEX_1_NAME ).withId (sampleEntity .getId ())
1722
+ .withObject (sampleEntity ).build ();
1723
+
1724
+ elasticsearchTemplate .index (idxQuery );
1725
+ elasticsearchTemplate .refresh (INDEX_1_NAME );
1726
+
1727
+ // when
1728
+ SearchQuery searchQuery = new NativeSearchQueryBuilder ().withQuery (matchAllQuery ())
1729
+ .withIndices (INDEX_1_NAME , INDEX_2_NAME ).withIndicesOptions (IndicesOptions .lenientExpandOpen ()).build ();
1730
+
1731
+ List <SampleEntity > entities = new ArrayList <>();
1732
+
1733
+ ScrolledPage <SampleEntity > scroll = elasticsearchTemplate .startScroll (scrollTimeInMillis , searchQuery ,
1734
+ SampleEntity .class , searchResultMapper );
1735
+
1736
+ entities .addAll (scroll .getContent ());
1737
+
1738
+ while (scroll .hasContent ()) {
1739
+ scroll = elasticsearchTemplate .continueScroll (scroll .getScrollId (), scrollTimeInMillis , SampleEntity .class ,
1740
+ searchResultMapper );
1741
+
1742
+ entities .addAll (scroll .getContent ());
1743
+ }
1744
+
1745
+ // then
1746
+ assertThat (entities ).isNotNull ();
1747
+ assertThat (entities .size ()).isGreaterThanOrEqualTo (1 );
1748
+ }
1749
+
1712
1750
@ Test // DATAES-479
1713
1751
public void shouldHonorTheHighlightBuilderOptions () {
1714
1752
0 commit comments