public final class IngestDocument
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
IngestDocument.MetaData |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INGEST_KEY |
Constructor and Description |
---|
IngestDocument(IngestDocument other)
Copy constructor that creates a new
IngestDocument which has exactly the same properties as the one provided as argument |
IngestDocument(java.util.Map<java.lang.String,java.lang.Object> sourceAndMetadata,
java.util.Map<java.lang.String,java.lang.Object> ingestMetadata)
Constructor needed for testing that allows to create a new
IngestDocument given the provided elasticsearch metadata,
source and ingest metadata. |
IngestDocument(java.lang.String index,
java.lang.String type,
java.lang.String id,
java.lang.String routing,
java.lang.String parent,
java.lang.String timestamp,
java.lang.String ttl,
java.util.Map<java.lang.String,java.lang.Object> source) |
IngestDocument(java.lang.String index,
java.lang.String type,
java.lang.String id,
java.lang.String routing,
java.lang.String parent,
java.lang.String timestamp,
java.lang.String ttl,
java.util.Map<java.lang.String,java.lang.Object> source,
boolean newDateFormat) |
Modifier and Type | Method and Description |
---|---|
void |
appendFieldValue(java.lang.String path,
java.lang.Object value)
Appends the provided value to the provided path in the document.
|
void |
appendFieldValue(TemplateService.Template fieldPathTemplate,
ValueSource valueSource)
Appends the provided value to the provided path in the document.
|
boolean |
equals(java.lang.Object obj) |
java.util.Map<IngestDocument.MetaData,java.lang.String> |
extractMetadata()
one time operation that extracts the metadata fields from the ingest document and returns them.
|
<T> T |
getFieldValue(java.lang.String path,
java.lang.Class<T> clazz)
Returns the value contained in the document for the provided path
|
<T> T |
getFieldValue(java.lang.String path,
java.lang.Class<T> clazz,
boolean ignoreMissing)
Returns the value contained in the document for the provided path
|
<T> T |
getFieldValue(TemplateService.Template pathTemplate,
java.lang.Class<T> clazz)
Returns the value contained in the document with the provided templated path
|
byte[] |
getFieldValueAsBytes(java.lang.String path)
Returns the value contained in the document for the provided path as a byte array.
|
byte[] |
getFieldValueAsBytes(java.lang.String path,
boolean ignoreMissing)
Returns the value contained in the document for the provided path as a byte array.
|
java.util.Map<java.lang.String,java.lang.Object> |
getIngestMetadata()
Returns the available ingest metadata fields, by default only timestamp, but it is possible to set additional ones.
|
java.util.Map<java.lang.String,java.lang.Object> |
getSourceAndMetadata()
Returns the document including its metadata fields, unless
extractMetadata() has been called, in which case the
metadata fields will not be present anymore. |
boolean |
hasField(java.lang.String path)
Checks whether the document contains a value for the provided path
|
boolean |
hasField(java.lang.String path,
boolean failOutOfRange)
Checks whether the document contains a value for the provided path
|
boolean |
hasField(TemplateService.Template fieldPathTemplate)
Checks whether the document contains a value for the provided templated path
|
int |
hashCode() |
void |
removeField(java.lang.String path)
Removes the field identified by the provided path.
|
void |
removeField(TemplateService.Template fieldPathTemplate)
Removes the field identified by the provided path.
|
java.lang.String |
renderTemplate(TemplateService.Template template) |
void |
setFieldValue(java.lang.String path,
java.lang.Object value)
Sets the provided value to the provided path in the document.
|
void |
setFieldValue(TemplateService.Template fieldPathTemplate,
ValueSource valueSource)
Sets the provided value to the provided path in the document.
|
java.lang.String |
toString() |
public static final java.lang.String INGEST_KEY
public IngestDocument(java.lang.String index, java.lang.String type, java.lang.String id, java.lang.String routing, java.lang.String parent, java.lang.String timestamp, java.lang.String ttl, java.util.Map<java.lang.String,java.lang.Object> source)
public IngestDocument(java.lang.String index, java.lang.String type, java.lang.String id, java.lang.String routing, java.lang.String parent, java.lang.String timestamp, java.lang.String ttl, java.util.Map<java.lang.String,java.lang.Object> source, boolean newDateFormat)
public IngestDocument(IngestDocument other)
IngestDocument
which has exactly the same properties as the one provided as argumentpublic IngestDocument(java.util.Map<java.lang.String,java.lang.Object> sourceAndMetadata, java.util.Map<java.lang.String,java.lang.Object> ingestMetadata)
IngestDocument
given the provided elasticsearch metadata,
source and ingest metadata. This is needed because the ingest metadata will be initialized with the current timestamp at
init time, which makes equality comparisons impossible in tests.public <T> T getFieldValue(java.lang.String path, java.lang.Class<T> clazz)
path
- The path within the document in dot-notationclazz
- The expected class of the field valuejava.lang.IllegalArgumentException
- if the path is null, empty, invalid, if the field doesn't exist
or if the field that is found at the provided path is not of the expected type.public <T> T getFieldValue(java.lang.String path, java.lang.Class<T> clazz, boolean ignoreMissing)
path
- The path within the document in dot-notationclazz
- The expected class of the field valueignoreMissing
- The flag to determine whether to throw an exception when `path` is not found in the document.java.lang.IllegalArgumentException
- only if ignoreMissing is false and the path is null, empty, invalid, if the field doesn't exist
or if the field that is found at the provided path is not of the expected type.public <T> T getFieldValue(TemplateService.Template pathTemplate, java.lang.Class<T> clazz)
pathTemplate
- The path within the document in dot-notationclazz
- The expected class fo the field valuejava.lang.IllegalArgumentException
- if the pathTemplate is null, empty, invalid, if the field doesn't exist,
or if the field that is found at the provided path is not of the expected type.public byte[] getFieldValueAsBytes(java.lang.String path)
path
- The path within the document in dot-notationjava.lang.IllegalArgumentException
- if the path is null, empty, invalid, if the field doesn't exist
or if the field that is found at the provided path is not of the expected type.public byte[] getFieldValueAsBytes(java.lang.String path, boolean ignoreMissing)
path
- The path within the document in dot-notationignoreMissing
- The flag to determine whether to throw an exception when `path` is not found in the document.java.lang.IllegalArgumentException
- if the path is null, empty, invalid, if the field doesn't exist
or if the field that is found at the provided path is not of the expected type.public boolean hasField(TemplateService.Template fieldPathTemplate)
fieldPathTemplate
- the template for the path within the document in dot-notationjava.lang.IllegalArgumentException
- if the path is null, empty or invalidpublic boolean hasField(java.lang.String path)
path
- The path within the document in dot-notationjava.lang.IllegalArgumentException
- if the path is null, empty or invalid.public boolean hasField(java.lang.String path, boolean failOutOfRange)
path
- The path within the document in dot-notationfailOutOfRange
- Whether to throw an IllegalArgumentException if array is accessed outside of its rangejava.lang.IllegalArgumentException
- if the path is null, empty or invalid.public void removeField(TemplateService.Template fieldPathTemplate)
fieldPathTemplate
- Resolves to the path with dot-notation within the documentjava.lang.IllegalArgumentException
- if the path is null, empty, invalid or if the field doesn't exist.public void removeField(java.lang.String path)
path
- the path of the field to be removedjava.lang.IllegalArgumentException
- if the path is null, empty, invalid or if the field doesn't exist.public void appendFieldValue(java.lang.String path, java.lang.Object value)
path
- The path within the document in dot-notationvalue
- The value or values to append to the existing onesjava.lang.IllegalArgumentException
- if the path is null, empty or invalid.public void appendFieldValue(TemplateService.Template fieldPathTemplate, ValueSource valueSource)
fieldPathTemplate
- Resolves to the path with dot-notation within the documentvalueSource
- The value source that will produce the value or values to append to the existing onesjava.lang.IllegalArgumentException
- if the path is null, empty or invalid.public void setFieldValue(java.lang.String path, java.lang.Object value)
appendFieldValue(String, Object)
to append values to lists instead.path
- The path within the document in dot-notationvalue
- The value to put in for the path keyjava.lang.IllegalArgumentException
- if the path is null, empty, invalid or if the value cannot be set to the
item identified by the provided path.public void setFieldValue(TemplateService.Template fieldPathTemplate, ValueSource valueSource)
fieldPathTemplate
- Resolves to the path with dot-notation within the documentvalueSource
- The value source that will produce the value to put in for the path keyjava.lang.IllegalArgumentException
- if the path is null, empty, invalid or if the value cannot be set to the
item identified by the provided path.public java.lang.String renderTemplate(TemplateService.Template template)
public java.util.Map<IngestDocument.MetaData,java.lang.String> extractMetadata()
public java.util.Map<java.lang.String,java.lang.Object> getIngestMetadata()
setFieldValue(String, Object)
and removeField(String)
public java.util.Map<java.lang.String,java.lang.Object> getSourceAndMetadata()
extractMetadata()
has been called, in which case the
metadata fields will not be present anymore.
Modify the document instead using setFieldValue(String, Object)
and removeField(String)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object