|
46 | 46 | import org.apache.lucene.sandbox.document.HalfFloatPoint;
|
47 | 47 | import org.apache.lucene.search.BoostQuery;
|
48 | 48 | import org.apache.lucene.search.IndexOrDocValuesQuery;
|
49 |
| -import org.apache.lucene.search.IndexSearcher; |
50 | 49 | import org.apache.lucene.search.IndexSortSortedNumericDocValuesRangeQuery;
|
51 | 50 | import org.apache.lucene.search.MatchNoDocsQuery;
|
52 |
| -import org.apache.lucene.search.PointInSetQuery; |
53 | 51 | import org.apache.lucene.search.Query;
|
54 | 52 | import org.apache.lucene.util.BytesRef;
|
55 | 53 | import org.apache.lucene.util.NumericUtils;
|
|
73 | 71 | import org.opensearch.search.DocValueFormat;
|
74 | 72 | import org.opensearch.search.lookup.SearchLookup;
|
75 | 73 | import org.opensearch.search.query.BitmapDocValuesQuery;
|
| 74 | +import org.opensearch.search.query.BitmapIndexQuery; |
76 | 75 |
|
77 | 76 | import java.io.IOException;
|
78 | 77 | import java.math.BigInteger;
|
|
81 | 80 | import java.util.ArrayList;
|
82 | 81 | import java.util.Arrays;
|
83 | 82 | import java.util.Collections;
|
84 |
| -import java.util.Iterator; |
85 | 83 | import java.util.List;
|
86 | 84 | import java.util.Map;
|
87 | 85 | import java.util.Objects;
|
@@ -888,10 +886,10 @@ public Query bitmapQuery(String field, BytesArray bitmapArray, boolean isSearcha
|
888 | 886 | }
|
889 | 887 |
|
890 | 888 | if (isSearchable && hasDocValues) {
|
891 |
| - return new IndexOrDocValuesQuery(bitmapIndexQuery(field, bitmap), new BitmapDocValuesQuery(field, bitmap)); |
| 889 | + return new IndexOrDocValuesQuery(new BitmapIndexQuery(field, bitmap), new BitmapDocValuesQuery(field, bitmap)); |
892 | 890 | }
|
893 | 891 | if (isSearchable) {
|
894 |
| - return bitmapIndexQuery(field, bitmap); |
| 892 | + return new BitmapIndexQuery(field, bitmap); |
895 | 893 | }
|
896 | 894 | return new BitmapDocValuesQuery(field, bitmap);
|
897 | 895 | }
|
@@ -1507,40 +1505,6 @@ public static Query unsignedLongRangeQuery(
|
1507 | 1505 | }
|
1508 | 1506 | return builder.apply(l, u);
|
1509 | 1507 | }
|
1510 |
| - |
1511 |
| - static PointInSetQuery bitmapIndexQuery(String field, RoaringBitmap bitmap) { |
1512 |
| - final BytesRef encoded = new BytesRef(new byte[Integer.BYTES]); |
1513 |
| - return new PointInSetQuery(field, 1, Integer.BYTES, new PointInSetQuery.Stream() { |
1514 |
| - |
1515 |
| - final Iterator<Integer> iterator = bitmap.iterator(); |
1516 |
| - |
1517 |
| - @Override |
1518 |
| - public BytesRef next() { |
1519 |
| - int value; |
1520 |
| - if (iterator.hasNext()) { |
1521 |
| - value = iterator.next(); |
1522 |
| - } else { |
1523 |
| - return null; |
1524 |
| - } |
1525 |
| - IntPoint.encodeDimension(value, encoded.bytes, 0); |
1526 |
| - return encoded; |
1527 |
| - } |
1528 |
| - }) { |
1529 |
| - @Override |
1530 |
| - public Query rewrite(IndexSearcher indexSearcher) throws IOException { |
1531 |
| - if (bitmap.isEmpty()) { |
1532 |
| - return new MatchNoDocsQuery(); |
1533 |
| - } |
1534 |
| - return super.rewrite(indexSearcher); |
1535 |
| - } |
1536 |
| - |
1537 |
| - @Override |
1538 |
| - protected String toString(byte[] value) { |
1539 |
| - assert value.length == Integer.BYTES; |
1540 |
| - return Integer.toString(IntPoint.decodeDimension(value, 0)); |
1541 |
| - } |
1542 |
| - }; |
1543 |
| - } |
1544 | 1508 | }
|
1545 | 1509 |
|
1546 | 1510 | /**
|
|
0 commit comments