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 ;
@@ -599,8 +599,10 @@ public void testIsBottomSortShardDisjoint() throws Exception {
599
599
FieldSortBuilder fieldSort = SortBuilders .fieldSort ("custom-date" );
600
600
try (DirectoryReader reader = writer .getReader ()) {
601
601
SearchExecutionContext context = createMockSearchExecutionContext (new IndexSearcher (reader ));
602
+ DocValueFormat [] dateValueFormat = new DocValueFormat [] {
603
+ context .getFieldType ("custom-date" ).docValueFormat (null , null ) };
602
604
assertTrue (fieldSort .isBottomSortShardDisjoint (context ,
603
- new SearchSortValuesAndFormats (new Object [] { 0L }, new DocValueFormat [] { DocValueFormat . RAW } )));
605
+ new SearchSortValuesAndFormats (new Object [] { 0L }, dateValueFormat )));
604
606
}
605
607
for (int i = 0 ; i < numDocs ; i ++) {
606
608
Document doc = new Document ();
@@ -613,27 +615,29 @@ public void testIsBottomSortShardDisjoint() throws Exception {
613
615
}
614
616
try (DirectoryReader reader = writer .getReader ()) {
615
617
SearchExecutionContext context = createMockSearchExecutionContext (new IndexSearcher (reader ));
618
+ DocValueFormat [] dateValueFormat = new DocValueFormat [] {
619
+ context .getFieldType ("custom-date" ).docValueFormat (null , null ) };
616
620
assertFalse (fieldSort .isBottomSortShardDisjoint (context , null ));
617
621
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
618
- new SearchSortValuesAndFormats (new Object [] { minValue }, new DocValueFormat [] { DocValueFormat . RAW } )));
622
+ new SearchSortValuesAndFormats (new Object [] { minValue }, dateValueFormat )));
619
623
assertTrue (fieldSort .isBottomSortShardDisjoint (context ,
620
- new SearchSortValuesAndFormats (new Object [] { minValue -1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
624
+ new SearchSortValuesAndFormats (new Object [] { minValue -1 }, dateValueFormat )));
621
625
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
622
- new SearchSortValuesAndFormats (new Object [] { minValue +1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
626
+ new SearchSortValuesAndFormats (new Object [] { minValue +1 }, dateValueFormat )));
623
627
fieldSort .order (SortOrder .DESC );
624
628
assertTrue (fieldSort .isBottomSortShardDisjoint (context ,
625
- new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
629
+ new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, dateValueFormat )));
626
630
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
627
- new SearchSortValuesAndFormats (new Object [] { maxValue }, new DocValueFormat [] { DocValueFormat . RAW } )));
631
+ new SearchSortValuesAndFormats (new Object [] { maxValue }, dateValueFormat )));
628
632
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
629
- new SearchSortValuesAndFormats (new Object [] { minValue }, new DocValueFormat [] { DocValueFormat . RAW } )));
633
+ new SearchSortValuesAndFormats (new Object [] { minValue }, dateValueFormat )));
630
634
fieldSort .setNestedSort (new NestedSortBuilder ("empty" ));
631
635
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
632
- new SearchSortValuesAndFormats (new Object [] { minValue -1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
636
+ new SearchSortValuesAndFormats (new Object [] { minValue -1 }, dateValueFormat )));
633
637
fieldSort .setNestedSort (null );
634
638
fieldSort .missing ("100" );
635
639
assertFalse (fieldSort .isBottomSortShardDisjoint (context ,
636
- new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, new DocValueFormat [] { DocValueFormat . RAW } )));
640
+ new SearchSortValuesAndFormats (new Object [] { maxValue +1 }, dateValueFormat )));
637
641
}
638
642
}
639
643
}
0 commit comments