Skip to content

Commit

Permalink
Using exact match instead of range
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi committed Jan 19, 2024
1 parent 67896d9 commit bae04e6
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
import org.opensearch.Version;
Expand Down Expand Up @@ -244,24 +245,11 @@ public Query termQuery(Object value, @Nullable QueryShardContext context) {
if (isSearchable() && hasDocValues()) {
return new IndexOrDocValuesQuery(
query,
SortedSetDocValuesField.newSlowRangeQuery(
((PointRangeQuery) query).getField(),
new BytesRef(((PointRangeQuery) query).getLowerPoint()),
new BytesRef(((PointRangeQuery) query).getUpperPoint()),
true,
true
)
SortedSetDocValuesField.newSlowExactQuery(name(), ((BytesRef) value))
);
}
if (hasDocValues()) {
// InetAddressPoint uses a rangeQuery internally for terms
return SortedSetDocValuesField.newSlowRangeQuery(
((PointRangeQuery) query).getField(),
new BytesRef(((PointRangeQuery) query).getLowerPoint()),
new BytesRef(((PointRangeQuery) query).getUpperPoint()),
true,
true
);
return SortedSetDocValuesField.newSlowExactQuery(name(), ((BytesRef) value));
}
return query;
}
Expand Down

0 comments on commit bae04e6

Please sign in to comment.