45
45
import org .elasticsearch .index .query .QueryBuilder ;
46
46
import org .elasticsearch .index .query .QueryBuilders ;
47
47
import org .elasticsearch .index .query .QueryRewriteContext ;
48
- import org .elasticsearch .index .query .SearchExecutionContext ;
49
48
import org .elasticsearch .index .query .QueryShardException ;
50
49
import org .elasticsearch .index .query .RangeQueryBuilder ;
50
+ import org .elasticsearch .index .query .SearchExecutionContext ;
51
51
import org .elasticsearch .search .DocValueFormat ;
52
52
import org .elasticsearch .search .MultiValueMode ;
53
53
import org .elasticsearch .search .SearchSortValuesAndFormats ;
@@ -636,8 +636,10 @@ public void testIsBottomSortShardDisjoint() throws Exception {
636
636
FieldSortBuilder fieldSort = SortBuilders .fieldSort ("custom-date" );
637
637
try (DirectoryReader reader = writer .getReader ()) {
638
638
SearchExecutionContext context = createMockSearchExecutionContext (new IndexSearcher (reader ));
639
+ DocValueFormat [] dateValueFormat = new DocValueFormat [] {
640
+ context .getFieldType ("custom-date" ).docValueFormat (null , null ) };
639
641
assertTrue (fieldSort .isBottomSortShardDisjoint (context ,
640
- new SearchSortValuesAndFormats (new Object [] { 0L }, new DocValueFormat [] { DocValueFormat . RAW } )));
642
+ new SearchSortValuesAndFormats (new Object [] { 0L }, dateValueFormat )));
641
643
}
642
644
for (int i = 0 ; i < numDocs ; i ++) {
643
645
Document doc = new Document ();
@@ -650,27 +652,29 @@ public void testIsBottomSortShardDisjoint() throws Exception {
650
652
}
651
653
try (DirectoryReader reader = writer .getReader ()) {
652
654
SearchExecutionContext context = createMockSearchExecutionContext (new IndexSearcher (reader ));
655
+ DocValueFormat [] dateValueFormat = new DocValueFormat [] {
656
+ context .getFieldType ("custom-date" ).docValueFormat (null , null ) };
653
657
assertFalse (fieldSort .isBottomSortShardDisjoint (context , null ));
654
658
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
655
- new SearchSortValuesAndFormats (new Object [] { minValue }, new DocValueFormat [] { DocValueFormat . RAW } )));
659
+ new SearchSortValuesAndFormats (new Object [] { minValue }, dateValueFormat )));
656
660
assertTrue (fieldSort .isBottomSortShardDisjoint (context ,
657
- new SearchSortValuesAndFormats (new Object [] { minValue -1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
661
+ new SearchSortValuesAndFormats (new Object [] { minValue -1 }, dateValueFormat )));
658
662
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
659
- new SearchSortValuesAndFormats (new Object [] { minValue +1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
663
+ new SearchSortValuesAndFormats (new Object [] { minValue +1 }, dateValueFormat )));
660
664
fieldSort .order (SortOrder .DESC );
661
665
assertTrue (fieldSort .isBottomSortShardDisjoint (context ,
662
- new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
666
+ new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, dateValueFormat )));
663
667
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
664
- new SearchSortValuesAndFormats (new Object [] { maxValue }, new DocValueFormat [] { DocValueFormat . RAW } )));
668
+ new SearchSortValuesAndFormats (new Object [] { maxValue }, dateValueFormat )));
665
669
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
666
- new SearchSortValuesAndFormats (new Object [] { minValue }, new DocValueFormat [] { DocValueFormat . RAW } )));
670
+ new SearchSortValuesAndFormats (new Object [] { minValue }, dateValueFormat )));
667
671
fieldSort .setNestedSort (new NestedSortBuilder ("empty" ));
668
672
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
669
- new SearchSortValuesAndFormats (new Object [] { minValue -1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
673
+ new SearchSortValuesAndFormats (new Object [] { minValue -1 }, dateValueFormat )));
670
674
fieldSort .setNestedSort (null );
671
675
fieldSort .missing ("100" );
672
676
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
673
- new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
677
+ new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, dateValueFormat )));
674
678
}
675
679
}
676
680
}
0 commit comments