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