Class: ElasticGraph::SchemaDefinition::Indexing::DerivedFields::AppendOnlySet Private

Inherits:
Object
  • Object
show all
Defined in:
elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Responsible for providing bits of the painless script specific to a ElasticGraph::SchemaDefinition::Indexing::DerivedIndexedType#append_only_set field.

Instance Method Summary collapse

Instance Method Details

#apply_operation_returning_update_statusString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a line of painless code to append a value to the set and return a boolean indicating if the set was updated.

Returns:

  • (String)

    a line of painless code to append a value to the set and return a boolean indicating if the set was updated.



28
29
30
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb', line 28

def apply_operation_returning_update_status
  %{appendOnlySet_idempotentlyInsertValues(data["#{source_field}"], ctx._source.#{destination_field})}
end

#function_definitionsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns painless functions required by append_only_set.

Returns:

  • (Array<String>)

    painless functions required by append_only_set.



23
24
25
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb', line 23

def function_definitions
  [IDEMPOTENTLY_INSERT_VALUES, IDEMPOTENTLY_INSERT_VALUE]
end

#setup_statementsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The statements here initialize the field to an empty list if it is null. This primarily happens when the document does not already exist, but can also happen when we add a new derived field to an existing type.

Returns:

  • (Array<String>)

    a list of painless statements that must be called at the top of the script to set things up.



36
37
38
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb', line 36

def setup_statements
  FieldInitializerSupport.build_empty_value_initializers(destination_field, leaf_value: FieldInitializerSupport::EMPTY_PAINLESS_LIST)
end