Package org.elasticsearch.script
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:
Inet4Address
es andInet6Address
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).InetAddress
es are not ordered, but we need to implement range queries with same same ordering asIpFieldMapper
. That also usesInetAddressPoint
so it saves us a lot of trouble to use the same representation.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IpFieldScript.Emit
static interface
IpFieldScript.Factory
static interface
IpFieldScript.LeafFactory
-
Field Summary
Fields Modifier and Type Field Description static ScriptContext<IpFieldScript.Factory>
CONTEXT
static java.lang.String[]
PARAMETERS
Fields inherited from class org.elasticsearch.script.AbstractFieldScript
fieldName, leafSearchLookup, MAX_VALUES
-
Constructor Summary
Constructors Constructor Description IpFieldScript(java.lang.String fieldName, java.util.Map<java.lang.String,java.lang.Object> params, SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext ctx)
-
Method Summary
Modifier and Type Method Description int
count()
The number of results produced the last timerunForDoc(int)
was called.void
emit(java.lang.String v)
void
runForDoc(int docId)
Execute the script for the provideddocId
.void
runForDoc(int docId, java.util.function.Consumer<java.net.InetAddress> consumer)
org.apache.lucene.util.BytesRef[]
values()
Values from the last timerunForDoc(int)
was called.Methods inherited from class org.elasticsearch.script.AbstractFieldScript
checkMaxSize, execute, extractFromSource, getDoc, getParams, setDocument
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
CONTEXT
-
PARAMETERS
public static final java.lang.String[] PARAMETERS
-
-
Constructor Details
-
IpFieldScript
public IpFieldScript(java.lang.String fieldName, java.util.Map<java.lang.String,java.lang.Object> params, SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext ctx)
-
-
Method Details
-
runForDoc
public final void runForDoc(int docId)Execute the script for the provideddocId
. -
runForDoc
public final void runForDoc(int docId, java.util.function.Consumer<java.net.InetAddress> consumer) -
values
public final org.apache.lucene.util.BytesRef[] values()Values from the last timerunForDoc(int)
was called. This array is mutable and will change with the next call ofrunForDoc(int)
. It is also oversized and will contain garbage at all indices at and abovecount()
.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 timerunForDoc(int)
was called. -
emit
public final void emit(java.lang.String v)
-