Class WriteField

java.lang.Object
org.elasticsearch.script.field.SourceMapField
org.elasticsearch.script.field.WriteField
All Implemented Interfaces:
Iterable<Object>, Field<Object>

public final class WriteField extends SourceMapField
  • Constructor Details

  • Method Details

    • move

      public WriteField move(String path)
      Move this path to another path in the map.
      Throws:
      IllegalArgumentException - if the other path has contents
    • move

      public WriteField move(WriteField path)
      Move this path to the path of the given WriteField, using that WriteFields root, which may be a NestedDocument.
      Throws:
      IllegalArgumentException - if the other path has contents
    • move

      public WriteField move(Object path)
      The painless API for move, delegates to move(String) or move(WriteField), throws an IllegalArgumentException if is neither a String nor a WriteField. This is necessary because Painless does not support method overloading, only arity overloading.
    • overwrite

      public WriteField overwrite(String path)
      Move this path to another path in the map, overwriting the destination path if it exists. If this Field has no value, the value at is removed.
    • overwrite

      public WriteField overwrite(WriteField path)
      Move this path to the path represented by another WriteField, using that WriteFields root, which may be a NestedDocument. Overwrites the destination path if it exists. If this Field has no value, the value at is removed.
    • overwrite

      public WriteField overwrite(Object path)
      The painless API for overwrite, delegates to overwrite(String) or overwrite(WriteField), throws an IllegalArgumentException if is neither a String nor a WriteField. This is necessary because Painless does not support method overloading, only arity overloading.
    • remove

      public void remove()
      Removes this path from the map.
    • set

      public WriteField set(Object value)
      Sets the value for this path. Creates nested path if necessary.
    • append

      public WriteField append(Object value)
      Appends a value to this path. Creates the path and the List at the leaf if necessary.
    • getListIterator

      protected Iterator<Object> getListIterator(List<?> list)
      Description copied from class: SourceMapField
      Get an iterator for the given list that cannot mutate the underlying list. Subclasses can override this method to allow for mutating iterators.
      Overrides:
      getListIterator in class SourceMapField
      Parameters:
      list - the list to get an iterator for
      Returns:
      an iterator that cannot mutate the underlying list
    • transform

      public WriteField transform(Function<Object,Object> transformer)
      Update each value at this path with the Function.
    • deduplicate

      public WriteField deduplicate()
      Remove all duplicate values from this path. List order is not preserved.
    • removeValuesIf

      public WriteField removeValuesIf(Predicate<Object> filter)
      Remove all values at this path that match . If there is only one value and it matches , the mapping is removed, however empty Lists are retained.
    • removeValue

      public WriteField removeValue(int index)
      Remove the value at , if it exists. If there is only one value and is zero, remove the mapping.
    • doc

      public NestedDocument doc()
      Append a NestedDocument to this field and return it.
    • doc

      public NestedDocument doc(int index)
      Returns a NestedDocument at the index, if index is beyond the end of the List, creates empty NestedDocument through the end of the array to the index.
    • docs

      public Iterable<NestedDocument> docs()
      Iterable over all NestedDocuments in this field.