java.lang.Object
org.apache.lucene.document.Field
org.apache.lucene.document.InetAddressRange
- All Implemented Interfaces:
IndexableField
An indexed InetAddress Range Field
This field indexes an InetAddress range defined as a min/max pairs. It is single
dimension only (indexed as two 16 byte paired values).
Multiple values are supported.
This field defines the following static factory methods for common search operations over Ip Ranges
newIntersectsQuery()matches ip ranges that intersect the defined search range.newWithinQuery()matches ip ranges that are within the defined search range.newContainsQuery()matches ip ranges that contain the defined search range.newCrossesQuery()matches ip ranges that cross the defined search range
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.document.Field
Field.Store -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe number of bytes per dimension : sync w/InetAddressPointprivate static final FieldTypeFields inherited from class org.apache.lucene.document.Field
fieldsData, name, tokenStream, type -
Constructor Summary
ConstructorsConstructorDescriptionInetAddressRange(String name, InetAddress min, InetAddress max) Create a new InetAddressRange from min/max value -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]encode(InetAddress min, InetAddress max) encode the min/max range and return the byte arrayprivate static voidencode(InetAddress min, InetAddress max, byte[] bytes) encode the min/max range into the provided byte arraystatic QuerynewContainsQuery(String field, InetAddress min, InetAddress max) Create a query for matching indexed ip ranges thatCONTAINSthe defined range.static QuerynewCrossesQuery(String field, InetAddress min, InetAddress max) Create a query for matching indexed ip ranges thatCROSSthe defined range.static QuerynewIntersectsQuery(String field, InetAddress min, InetAddress max) Create a query for matching indexed ip ranges thatINTERSECTthe defined range.private static QuerynewRelationQuery(String field, InetAddress min, InetAddress max, RangeFieldQuery.QueryType relation) helper method for creating the desired relational querystatic QuerynewWithinQuery(String field, InetAddress min, InetAddress max) Create a query for matching indexed ip ranges that areWITHINthe defined range.voidsetRangeValues(InetAddress min, InetAddress max) Change (or set) the min/max values of the field.private static StringtoString(byte[] ranges, int dimension) Returns the String representation for the range at the given dimensionMethods inherited from class org.apache.lucene.document.Field
binaryValue, fieldType, getCharSequenceValue, invertableType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, storedValue, stringValue, tokenStream, tokenStreamValue, toString
-
Field Details
-
BYTES
public static final int BYTESThe number of bytes per dimension : sync w/InetAddressPoint- See Also:
-
TYPE
-
-
Constructor Details
-
InetAddressRange
Create a new InetAddressRange from min/max value- Parameters:
name- field name. must not be null.min- range min value; defined as anInetAddressmax- range max value; defined as anInetAddress
-
-
Method Details
-
setRangeValues
Change (or set) the min/max values of the field.- Parameters:
min- range min value; defined as anInetAddressmax- range max value; defined as anInetAddress
-
encode
encode the min/max range into the provided byte array -
encode
encode the min/max range and return the byte array -
newIntersectsQuery
Create a query for matching indexed ip ranges thatINTERSECTthe defined range.- Parameters:
field- field name. must not be null.min- range min value; provided as anInetAddressmax- range max value; provided as anInetAddress- Returns:
- query for matching intersecting ranges (overlap, within, crosses, or contains)
- Throws:
IllegalArgumentException- iffieldis null,minormaxis invalid
-
newContainsQuery
Create a query for matching indexed ip ranges thatCONTAINSthe defined range.- Parameters:
field- field name. must not be null.min- range min value; provided as anInetAddressmax- range max value; provided as anInetAddress- Returns:
- query for matching intersecting ranges (overlap, within, crosses, or contains)
- Throws:
IllegalArgumentException- iffieldis null,minormaxis invalid
-
newWithinQuery
Create a query for matching indexed ip ranges that areWITHINthe defined range.- Parameters:
field- field name. must not be null.min- range min value; provided as anInetAddressmax- range max value; provided as anInetAddress- Returns:
- query for matching intersecting ranges (overlap, within, crosses, or contains)
- Throws:
IllegalArgumentException- iffieldis null,minormaxis invalid
-
newCrossesQuery
Create a query for matching indexed ip ranges thatCROSSthe defined range.- Parameters:
field- field name. must not be null.min- range min value; provided as anInetAddressmax- range max value; provided as anInetAddress- Returns:
- query for matching intersecting ranges (overlap, within, crosses, or contains)
- Throws:
IllegalArgumentException- iffieldis null,minormaxis invalid
-
newRelationQuery
private static Query newRelationQuery(String field, InetAddress min, InetAddress max, RangeFieldQuery.QueryType relation) helper method for creating the desired relational query -
toString
Returns the String representation for the range at the given dimension- Parameters:
ranges- the encoded ranges, never nulldimension- the dimension of interest (not used for this field)- Returns:
- The string representation for the range at the provided dimension
-