java.lang.Object
org.elasticsearch.script.Metadata
- Direct Known Subclasses:
ReindexMetadata
,UpdateByQueryMetadata
,UpdateMetadata
Ingest and update metadata available to write scripts.
Provides a map-like interface for backwards compatibility with the ctx map.
-
put(String, Object)
- get(String)
- remove(String)
- containsKey(String)
- containsValue(Object)
- keySet()
for iteration
- size()
- isAvailable(String)
for determining if a key is a metadata key
Provides getters and setters for script usage.
Validates all updates whether originating in map-like interface or setters.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
The properties of a metadata field.static enum
The operation being performed on the value in the map. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final Metadata.FieldProperty<?>
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
static Metadata.FieldProperty<Number>
protected static final String
static Metadata.FieldProperty<Object>
protected static final String
protected static final String
static Metadata.FieldProperty<String>
protected static final String
protected static final String
protected static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
containsKey
(String key) Does the metadata contain the key?boolean
containsValue
(Object value) Does the metadata contain the value.boolean
Get the value associated withgetId()
getIndex()
getMap()
Get the backing map, if modified then the guarantees of this class may not holdgetNow()
protected Number
Get theNumber
associated with key, or nullgetOp()
protected String
Get the String version of the value associated withkey
, or nulllong
int
hashCode()
boolean
isAvailable
(String key) Is this key a Metadata key? Aremove(java.lang.String)
d key would return false forcontainsKey(String)
but true for this call.keySet()
Return the list of keys with mappingsCreate the mapping from key to value.Remove the mapping associated withvoid
void
void
void
setRouting
(String routing) void
setVersion
(long version) void
setVersionType
(String versionType) int
size()
The number of metadata keys currently mapped.static BiConsumer<String,
String> stringSetValidator
(Set<String> valid) protected void
Check that all metadata map contains only valid metadata and no extraneous keys
-
Field Details
-
INDEX
- See Also:
-
ID
- See Also:
-
ROUTING
- See Also:
-
VERSION_TYPE
- See Also:
-
VERSION
- See Also:
-
TYPE
- See Also:
-
NOW
- See Also:
-
OP
- See Also:
-
IF_SEQ_NO
- See Also:
-
IF_PRIMARY_TERM
- See Also:
-
DYNAMIC_TEMPLATES
- See Also:
-
ObjectField
-
StringField
-
LongField
-
map
-
BAD_KEY
-
-
Constructor Details
-
Metadata
Constructs a new Metadata object represented by the given map and properties.The passed-in map is used directly -- subsequent modifications to it outside the methods of this class may result in undefined behavior. Note also that mutation-like methods (e.g. setters, etc) on this class rely on the map being mutable, which is the expected use for this class.
The properties map is used directly as well, but we verify at runtime that it must be an immutable map (i.e. constructed via a call to
Map.of()
(or similar) in production, or viaMap.copyOf(Map)
} in tests). Since it must be an immutable map, subsequent modifications are not possible.- Parameters:
map
- the backing map for this metadata instanceproperties
- the immutable map of defined properties for the type of metadata represented by this instance
-
-
Method Details
-
validateMetadata
protected void validateMetadata()Check that all metadata map contains only valid metadata and no extraneous keys -
getIndex
-
setIndex
-
getId
-
setId
-
getRouting
-
setRouting
-
getVersionType
-
setVersionType
-
getVersion
public long getVersion() -
setVersion
public void setVersion(long version) -
getNow
-
getOp
-
setOp
-
getIfSeqNo
-
getIfPrimaryTerm
-
getDynamicTemplates
-
getString
Get the String version of the value associated withkey
, or null -
getNumber
Get theNumber
associated with key, or null- Throws:
IllegalArgumentException
- if the value is not aNumber
-
isAvailable
Is this key a Metadata key? Aremove(java.lang.String)
d key would return false forcontainsKey(String)
but true for this call. -
put
Create the mapping from key to value.- Throws:
IllegalArgumentException
- ifisAvailable(String)
is false or the key cannot be updated to the value.
-
containsKey
Does the metadata contain the key? -
containsValue
Does the metadata contain the value. -
get
Get the value associated with -
remove
Remove the mapping associated with- Throws:
IllegalArgumentException
- ifisAvailable(String)
is false or the key cannot be removed.
-
keySet
Return the list of keys with mappings -
size
public int size()The number of metadata keys currently mapped. -
clone
-
getMap
Get the backing map, if modified then the guarantees of this class may not hold -
equals
-
hashCode
public int hashCode() -
stringSetValidator
-