public class InetAddressPoint extends Field
InetAddress
field.
Finding all documents within a range at search time is efficient. Multiple values for the same field in one document is allowed.
This field defines static factory methods for creating common queries:
newExactQuery(String, InetAddress)
for matching an exact network address.
newPrefixQuery(String, InetAddress, int)
for matching a network based on CIDR prefix.
newRangeQuery(String, InetAddress, InetAddress)
for matching arbitrary network address ranges.
newSetQuery(String, InetAddress...)
for matching a set of 1D values.
This field supports both IPv4 and IPv6 addresses: IPv4 addresses are converted
to IPv4-Mapped IPv6 Addresses:
indexing 1.2.3.4
is the same as indexing ::FFFF:1.2.3.4
.
PointValues
Field.Store
Modifier and Type | Field and Description |
---|---|
static int |
BYTES
The number of bytes per dimension: 128 bits
|
static InetAddress |
MAX_VALUE
The maximum value that an ip address can hold.
|
static InetAddress |
MIN_VALUE
The minimum value that an ip address can hold.
|
boost, fieldsData, name, tokenStream, type
Constructor and Description |
---|
InetAddressPoint(String name,
InetAddress point)
Creates a new InetAddressPoint, indexing the
provided address.
|
Modifier and Type | Method and Description |
---|---|
static InetAddress |
decode(byte[] value)
Decodes InetAddress value from binary encoding
|
static byte[] |
encode(InetAddress value)
Encode InetAddress value into binary encoding
|
static Query |
newExactQuery(String field,
InetAddress value)
Create a query for matching a network address.
|
static Query |
newPrefixQuery(String field,
InetAddress value,
int prefixLength)
Create a prefix query for matching a CIDR network range.
|
static Query |
newRangeQuery(String field,
InetAddress lowerValue,
InetAddress upperValue)
Create a range query for network addresses.
|
static Query |
newSetQuery(String field,
InetAddress... values)
Create a query matching any of the specified 1D values.
|
static InetAddress |
nextDown(InetAddress address)
Return the
InetAddress that compares immediately less than
address . |
static InetAddress |
nextUp(InetAddress address)
Return the
InetAddress that compares immediately greater than
address . |
void |
setBytesValue(BytesRef bytes) |
void |
setInetAddressValue(InetAddress value)
Change the values of this field
|
String |
toString() |
binaryValue, boost, fieldType, name, numericValue, readerValue, setBoost, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
public static final int BYTES
public static final InetAddress MIN_VALUE
public static final InetAddress MAX_VALUE
public InetAddressPoint(String name, InetAddress point)
name
- field namepoint
- InetAddress valueIllegalArgumentException
- if the field name or value is null.public static InetAddress nextUp(InetAddress address)
InetAddress
that compares immediately greater than
address
.ArithmeticException
- if the provided address is the
maximum ip address
public static InetAddress nextDown(InetAddress address)
InetAddress
that compares immediately less than
address
.ArithmeticException
- if the provided address is the
minimum ip address
public void setInetAddressValue(InetAddress value)
public void setBytesValue(BytesRef bytes)
setBytesValue
in class Field
public static byte[] encode(InetAddress value)
public static InetAddress decode(byte[] value)
public static Query newExactQuery(String field, InetAddress value)
field
- field name. must not be null
.value
- exact valueIllegalArgumentException
- if field
is null.public static Query newPrefixQuery(String field, InetAddress value, int prefixLength)
field
- field name. must not be null
.value
- any host addressprefixLength
- the network prefix length for this address. This is also known as the subnet mask in the context of IPv4 addresses.IllegalArgumentException
- if field
is null, or prefixLength is invalid.public static Query newRangeQuery(String field, InetAddress lowerValue, InetAddress upperValue)
You can have half-open ranges (which are in fact </≤ or >/≥ queries)
by setting lowerValue = InetAddressPoint.MIN_VALUE
or
upperValue = InetAddressPoint.MAX_VALUE
.
Ranges are inclusive. For exclusive ranges, pass InetAddressPoint#nextUp(lowerValue)
or InetAddressPoint#nexDown(upperValue)
.
field
- field name. must not be null
.lowerValue
- lower portion of the range (inclusive). must not be null.upperValue
- upper portion of the range (inclusive). must not be null.IllegalArgumentException
- if field
is null, lowerValue
is null,
or upperValue
is nullpublic static Query newSetQuery(String field, InetAddress... values)
TermsQuery
.field
- field name. must not be null
.values
- all values to matchCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.