java.lang.Object
org.elasticsearch.script.DocBasedScript
org.elasticsearch.script.AbstractFieldScript
org.elasticsearch.script.IpFieldScript
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 ClassesModifier and TypeClassDescriptionstatic class
static interface
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ScriptContext
<IpFieldScript.Factory> static final String[]
static final IpFieldScript.Factory
Fields inherited from class org.elasticsearch.script.AbstractFieldScript
fieldName, MAX_VALUES, source
Fields inherited from class org.elasticsearch.script.DocBasedScript
docReader
-
Constructor Summary
ConstructorsConstructorDescriptionIpFieldScript
(String fieldName, Map<String, Object> params, SearchLookup searchLookup, OnScriptError onScriptError, org.apache.lucene.index.LeafReaderContext ctx) -
Method Summary
Modifier and TypeMethodDescriptionfinal int
count()
The number of results produced the last timeAbstractFieldScript.runForDoc(int)
was called.final void
protected void
static IpFieldScript.Factory
leafAdapter
(Function<SearchLookup, CompositeFieldScript.LeafFactory> parentFactory) protected void
final void
runForDoc
(int docId, Consumer<InetAddress> consumer) final org.apache.lucene.util.BytesRef[]
values()
Values from the last timeAbstractFieldScript.runForDoc(int)
was called.Methods inherited from class org.elasticsearch.script.AbstractFieldScript
checkMaxSize, emitFromCompositeScript, emitFromSource, emitValueFromCompositeScript, execute, extractFromSource, getParams, newContext, runForDoc
Methods inherited from class org.elasticsearch.script.DocBasedScript
docAsMap, field, fields, getDoc, setDocument, source
-
Field Details
-
CONTEXT
-
PARSE_FROM_SOURCE
-
PARAMETERS
-
-
Constructor Details
-
IpFieldScript
public IpFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, OnScriptError onScriptError, org.apache.lucene.index.LeafReaderContext ctx)
-
-
Method Details
-
leafAdapter
public static IpFieldScript.Factory leafAdapter(Function<SearchLookup, CompositeFieldScript.LeafFactory> parentFactory) -
prepareExecute
protected void prepareExecute()- Specified by:
prepareExecute
in classAbstractFieldScript
-
runForDoc
-
values
public final org.apache.lucene.util.BytesRef[] values()Values from the last timeAbstractFieldScript.runForDoc(int)
was called. This array is mutable and will change with the next call ofAbstractFieldScript.runForDoc(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 timeAbstractFieldScript.runForDoc(int)
was called. -
emitFromObject
- Specified by:
emitFromObject
in classAbstractFieldScript
-
emit
-