Class: ElasticGraph::Indexer::RecordPreparer
- Inherits:
-
Object
- Object
- ElasticGraph::Indexer::RecordPreparer
- Defined in:
- lib/elastic_graph/indexer/record_preparer.rb
Defined Under Namespace
Modules: Identity Classes: Factory
Instance Method Summary collapse
-
#initialize(indexing_preparer_by_scalar_type_name, type_metas) ⇒ RecordPreparer
constructor
A new instance of RecordPreparer.
-
#prepare_for_index(type_name, record) ⇒ Object
Prepares the given payload for being indexed into the named index.
Constructor Details
#initialize(indexing_preparer_by_scalar_type_name, type_metas) ⇒ RecordPreparer
Returns a new instance of RecordPreparer.
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/elastic_graph/indexer/record_preparer.rb', line 84 def initialize(indexing_preparer_by_scalar_type_name, ) @indexing_preparer_by_scalar_type_name = indexing_preparer_by_scalar_type_name @eg_meta_by_field_name_by_concrete_type = .to_h do || [.name, .] end @types_requiring_typename = .filter_map do || .name if .requires_typename end.to_set end |
Instance Method Details
#prepare_for_index(type_name, record) ⇒ Object
Prepares the given payload for being indexed into the named index. This allows any value or field name conversion to happen before we index the data, to support the few cases where we expect differences between the payload received by the ElasticGraph indexer, and the payload we send to the datastore.
As part of preparing the data, we also drop any ‘record` fields that are not defined in our schema. This allows us to handle events that target multiple indices (e.g. v1 and v2) for the same type. The event can contain the set union of fields and this will take care of dropping any unsupported fields before we attempt to index the record.
Note: this method does not mutate the given ‘record`. Instead it returns a copy with any updates applied to it.
109 110 111 |
# File 'lib/elastic_graph/indexer/record_preparer.rb', line 109 def prepare_for_index(type_name, record) prepare_value_for_indexing(record, type_name) end |