Skip to content

Commit

Permalink
drop redundant brackets
Browse files Browse the repository at this point in the history
Signed-off-by: mikhail-khludnev <[email protected]>
  • Loading branch information
mkhludnev authored and mikhail-khludnev committed Nov 14, 2024
1 parent c56ee66 commit 6eb18ba
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,20 @@ protected Object parseSourceValue(Object value) {
public Query termQuery(Object value, @Nullable QueryShardContext context) {
failIfNotIndexedAndNoDocValues();
final PointRangeQuery pointQuery;
{
final Query query;
if (value instanceof InetAddress) {
query = InetAddressPoint.newExactQuery(name(), (InetAddress) value);
if (value instanceof InetAddress) {
pointQuery = (PointRangeQuery) InetAddressPoint.newExactQuery(name(), (InetAddress) value);
} else {
if (value instanceof BytesRef) {
value = ((BytesRef) value).utf8ToString();
}
String term = value.toString();
if (term.contains("/")) {
final Tuple<InetAddress, Integer> cidr = InetAddresses.parseCidr(term);
pointQuery = (PointRangeQuery) InetAddressPoint.newPrefixQuery(name(), cidr.v1(), cidr.v2());
} else {
if (value instanceof BytesRef) {
value = ((BytesRef) value).utf8ToString();
}
String term = value.toString();
if (term.contains("/")) {
final Tuple<InetAddress, Integer> cidr = InetAddresses.parseCidr(term);
query = InetAddressPoint.newPrefixQuery(name(), cidr.v1(), cidr.v2());
} else {
InetAddress address = InetAddresses.forString(term);
query = InetAddressPoint.newExactQuery(name(), address);
}
InetAddress address = InetAddresses.forString(term);
pointQuery = (PointRangeQuery) InetAddressPoint.newExactQuery(name(), address);
}
pointQuery = (PointRangeQuery) query;
}
Query dvQuery = null;
if (hasDocValues()) {
Expand Down

0 comments on commit 6eb18ba

Please sign in to comment.