Class InetAddressPoint

    • Field Detail

      • BYTES

        public static final int BYTES
        The number of bytes per dimension: 128 bits
        See Also:
        Constant Field Values
      • IPV4_PREFIX

        static final byte[] IPV4_PREFIX
      • MIN_VALUE

        public static final java.net.InetAddress MIN_VALUE
        The minimum value that an ip address can hold.
      • MAX_VALUE

        public static final java.net.InetAddress MAX_VALUE
        The maximum value that an ip address can hold.
    • Constructor Detail

      • InetAddressPoint

        public InetAddressPoint​(java.lang.String name,
                                java.net.InetAddress point)
        Creates a new InetAddressPoint, indexing the provided address.
        Parameters:
        name - field name
        point - InetAddress value
        Throws:
        java.lang.IllegalArgumentException - if the field name or value is null.
    • Method Detail

      • nextUp

        public static java.net.InetAddress nextUp​(java.net.InetAddress address)
        Return the InetAddress that compares immediately greater than address.
        Throws:
        java.lang.ArithmeticException - if the provided address is the maximum ip address
      • nextDown

        public static java.net.InetAddress nextDown​(java.net.InetAddress address)
        Return the InetAddress that compares immediately less than address.
        Throws:
        java.lang.ArithmeticException - if the provided address is the minimum ip address
      • setInetAddressValue

        public void setInetAddressValue​(java.net.InetAddress value)
        Change the values of this field
      • setBytesValue

        public void setBytesValue​(BytesRef bytes)
        Description copied from class: Field
        Expert: change the value of this field. See Field.setStringValue(String).

        NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.

        Overrides:
        setBytesValue in class Field
      • toString

        public java.lang.String toString()
        Description copied from class: Field
        Prints a Field for human consumption.
        Overrides:
        toString in class Field
      • encode

        public static byte[] encode​(java.net.InetAddress value)
        Encode InetAddress value into binary encoding
      • decode

        public static java.net.InetAddress decode​(byte[] value)
        Decodes InetAddress value from binary encoding
      • newExactQuery

        public static Query newExactQuery​(java.lang.String field,
                                          java.net.InetAddress value)
        Create a query for matching a network address.
        Parameters:
        field - field name. must not be null.
        value - exact value
        Returns:
        a query matching documents with this exact value
        Throws:
        java.lang.IllegalArgumentException - if field is null.
      • newPrefixQuery

        public static Query newPrefixQuery​(java.lang.String field,
                                           java.net.InetAddress value,
                                           int prefixLength)
        Create a prefix query for matching a CIDR network range.
        Parameters:
        field - field name. must not be null.
        value - any host address
        prefixLength - the network prefix length for this address. This is also known as the subnet mask in the context of IPv4 addresses.
        Returns:
        a query matching documents with addresses contained within this network
        Throws:
        java.lang.IllegalArgumentException - if field is null, or prefixLength is invalid.
      • newRangeQuery

        public static Query newRangeQuery​(java.lang.String field,
                                          java.net.InetAddress lowerValue,
                                          java.net.InetAddress upperValue)
        Create a range query for network addresses.

        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).

        Parameters:
        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.
        Returns:
        a query matching documents within this range.
        Throws:
        java.lang.IllegalArgumentException - if field is null, lowerValue is null, or upperValue is null
      • newSetQuery

        public static Query newSetQuery​(java.lang.String field,
                                        java.net.InetAddress... values)
        Create a query matching any of the specified 1D values. This is the points equivalent of TermsQuery.
        Parameters:
        field - field name. must not be null.
        values - all values to match