From 3934e9ce69d62d02b2e36c52e1893faeb0463937 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Mon, 22 Jan 2024 11:57:46 -0800 Subject: [PATCH] Get point out of query and into value Signed-off-by: Harsha Vamsi Kalluri --- .../java/org/opensearch/index/mapper/IpFieldMapper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java index c1db6b0415519..db8da8a949d6f 100644 --- a/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java @@ -243,21 +243,22 @@ public Query termQuery(Object value, @Nullable QueryShardContext context) { } if (isSearchable() && hasDocValues()) { String term = value.toString(); - if (value instanceof String) value = new BytesRef(((String) value)); if (term.contains("/")) { final Tuple cidr = InetAddresses.parseCidr(term); return InetAddressPoint.newPrefixQuery(name(), cidr.v1(), cidr.v2()); } - return new IndexOrDocValuesQuery(query, SortedSetDocValuesField.newSlowExactQuery(name(), (BytesRef) (value))); + return new IndexOrDocValuesQuery( + query, + SortedSetDocValuesField.newSlowExactQuery(name(), new BytesRef(((PointRangeQuery) query).getLowerPoint())) + ); } if (hasDocValues()) { String term = value.toString(); - if (value instanceof String) value = new BytesRef(((String) value)); if (term.contains("/")) { final Tuple cidr = InetAddresses.parseCidr(term); return InetAddressPoint.newPrefixQuery(name(), cidr.v1(), cidr.v2()); } - return SortedSetDocValuesField.newSlowExactQuery(name(), ((BytesRef) value)); + return SortedSetDocValuesField.newSlowExactQuery(name(), new BytesRef(((PointRangeQuery) query).getLowerPoint())); } return query; }