Class IpFieldScript

java.lang.Object
org.elasticsearch.script.AbstractFieldScript
org.elasticsearch.script.IpFieldScript

public abstract class IpFieldScript extends AbstractFieldScript
Script producing IP addresses. Unlike the other AbstractFieldScripts which deal with their native java objects this converts its values to the same format that Lucene uses to store its fields, InetAddressPoint. There are a few compelling reasons to do this:
  • Inet4Addresses and Inet6Address are not comparable with one another. That is correct in some contexts, but not for our queries. Our queries must consider the IPv4 address equal to the address that it maps to in IPv6 rfc4291).
  • InetAddresses are not ordered, but we need to implement range queries with same same ordering as IpFieldMapper. That also uses InetAddressPoint so it saves us a lot of trouble to use the same representation.
  • Field Details

  • Constructor Details

  • Method Details

    • runForDoc

      public final void runForDoc(int docId)
      Execute the script for the provided docId.
    • runForDoc

      public final void runForDoc(int docId, Consumer<InetAddress> consumer)
    • values

      public final org.apache.lucene.util.BytesRef[] values()
      Values from the last time runForDoc(int) was called. This array is mutable and will change with the next call of runForDoc(int). It is also oversized and will contain garbage at all indices at and above count().

      All values are IPv6 addresses so they are 16 bytes. IPv4 addresses are encoded by rfc4291.

    • count

      public final int count()
      The number of results produced the last time runForDoc(int) was called.
    • emitFromObject

      protected void emitFromObject(Object v)
      Specified by:
      emitFromObject in class AbstractFieldScript
    • emit

      public final void emit(String v)