13
13
import org .apache .lucene .analysis .core .WhitespaceAnalyzer ;
14
14
import org .apache .lucene .document .Document ;
15
15
import org .apache .lucene .document .LongPoint ;
16
+ import org .apache .lucene .document .NumericDocValuesField ;
16
17
import org .apache .lucene .index .IndexReader ;
17
18
import org .apache .lucene .search .IndexSearcher ;
18
19
import org .apache .lucene .search .Query ;
20
+ import org .apache .lucene .search .Sort ;
21
+ import org .apache .lucene .search .SortField ;
19
22
import org .apache .lucene .search .TopDocs ;
20
23
import org .apache .lucene .search .TotalHits ;
21
24
import org .apache .lucene .store .Directory ;
26
29
27
30
import java .io .IOException ;
28
31
32
+ import static java .util .Arrays .asList ;
29
33
import static org .apache .lucene .document .LongPoint .pack ;
30
34
import static org .mockito .Mockito .mock ;
31
35
@@ -112,7 +116,6 @@ protected String toString(int dimension, byte[] value) {
112
116
}
113
117
}
114
118
115
- @ AwaitsFix (bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/15600" )
116
119
public void testApproximateRangeWithSizeUnderDefault () throws IOException {
117
120
try (Directory directory = newDirectory ()) {
118
121
try (RandomIndexWriter iw = new RandomIndexWriter (random (), directory , new WhitespaceAnalyzer ())) {
@@ -151,7 +154,6 @@ protected String toString(int dimension, byte[] value) {
151
154
}
152
155
}
153
156
154
- @ AwaitsFix (bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/15600" )
155
157
public void testApproximateRangeWithSizeOverDefault () throws IOException {
156
158
try (Directory directory = newDirectory ()) {
157
159
try (RandomIndexWriter iw = new RandomIndexWriter (random (), directory , new WhitespaceAnalyzer ())) {
@@ -196,7 +198,6 @@ protected String toString(int dimension, byte[] value) {
196
198
}
197
199
}
198
200
199
- @ AwaitsFix (bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/15600" )
200
201
public void testApproximateRangeShortCircuit () throws IOException {
201
202
try (Directory directory = newDirectory ()) {
202
203
try (RandomIndexWriter iw = new RandomIndexWriter (random (), directory , new WhitespaceAnalyzer ())) {
@@ -256,8 +257,7 @@ public void testApproximateRangeShortCircuitAscSort() throws IOException {
256
257
for (int v = 0 ; v < dims ; v ++) {
257
258
scratch [v ] = i ;
258
259
}
259
- doc .add (new LongPoint ("point" , scratch ));
260
- iw .addDocument (doc );
260
+ iw .addDocument (asList (new LongPoint ("point" , scratch [0 ]), new NumericDocValuesField ("point" , scratch [0 ])));
261
261
}
262
262
iw .flush ();
263
263
iw .forceMerge (1 );
@@ -280,8 +280,9 @@ protected String toString(int dimension, byte[] value) {
280
280
Query query = LongPoint .newRangeQuery ("point" , lower , upper );
281
281
;
282
282
IndexSearcher searcher = new IndexSearcher (reader );
283
- TopDocs topDocs = searcher .search (approximateQuery , 10 );
284
- TopDocs topDocs1 = searcher .search (query , 10 );
283
+ Sort sort = new Sort (new SortField ("point" , SortField .Type .LONG ));
284
+ TopDocs topDocs = searcher .search (approximateQuery , 10 , sort );
285
+ TopDocs topDocs1 = searcher .search (query , 10 , sort );
285
286
286
287
// since we short-circuit from the approx range at the end of size these will not be equal
287
288
assertNotEquals (topDocs .totalHits , topDocs1 .totalHits );
0 commit comments