diff --git a/CHANGELOG.md b/CHANGELOG.md index 262d2e2..b91a649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * Add preload_lazy_attributes option to the import in order to fetch the lazy attributes in a single query before bulk indexing ## 0.3.6 - 2024-08-07 -* Esse::LazyDocumentHeader#to_doc return `Esse::LazyDocumentHeader::Document` instance to properly separate context metadata from document source +* Esse::LazyDocumentHeader#to_doc return `Esse::DocumentForPartialUpdate` instance to properly separate context metadata from document source * Add `.collection_class` method to the `Esse::Repository` class to let external plugins and extensions to access it instead of read @collection_proc variable ## 0.3.5 - 2024-08-02 diff --git a/lib/esse/core.rb b/lib/esse/core.rb index 1b5bf67..7d844f5 100644 --- a/lib/esse/core.rb +++ b/lib/esse/core.rb @@ -6,6 +6,7 @@ module Esse require_relative 'primitives' require_relative 'collection' require_relative 'document' + require_relative 'document_for_partial_update' require_relative 'document_lazy_attribute' require_relative 'lazy_document_header' require_relative 'hash_document' diff --git a/lib/esse/document.rb b/lib/esse/document.rb index a47f9f6..9c3a413 100644 --- a/lib/esse/document.rb +++ b/lib/esse/document.rb @@ -84,11 +84,16 @@ def ignore_on_delete? id.nil? end - def ==(other) - other.is_a?(self.class) && ( - id == other.id && type == other.type && routing == other.routing && meta == other.meta && source == other.source - ) + def eql?(other, match_lazy_doc_header: false) + if match_lazy_doc_header && other.is_a?(LazyDocumentHeader) + other.eql?(self) + else + other.is_a?(self.class) && ( + id.to_s == other.id.to_s && type == other.type && routing == other.routing && meta == other.meta && source == other.source + ) + end end + alias_method :==, :eql? def doc_header { _id: id }.tap do |h| @@ -120,5 +125,9 @@ def mutated_source @__mutated_source__ ||= source.merge(@__mutations__) end + + def document_for_partial_update(source) + DocumentForPartialUpdate.new(self, source: source) + end end end diff --git a/lib/esse/document_for_partial_update.rb b/lib/esse/document_for_partial_update.rb new file mode 100644 index 0000000..88b19f0 --- /dev/null +++ b/lib/esse/document_for_partial_update.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Esse + class DocumentForPartialUpdate < Esse::Document + extend Forwardable + + def_delegators :object, :id, :type, :routing, :options + + attr_reader :source + + def initialize(lazy_header, source:) + @source = source + super(lazy_header) + end + end +end diff --git a/lib/esse/index/documents.rb b/lib/esse/index/documents.rb index b6dc6dc..91e88ac 100644 --- a/lib/esse/index/documents.rb +++ b/lib/esse/index/documents.rb @@ -252,7 +252,7 @@ def import(*repo_types, context: {}, eager_load_lazy_attributes: false, update_l attrs = lazy_attrs_to_eager_load.is_a?(Array) ? lazy_attrs_to_eager_load : repo.lazy_document_attribute_names(lazy_attrs_to_eager_load) attrs.each do |attr_name| repo.retrieve_lazy_attribute_values(attr_name, entries).each do |doc_header, value| - doc = entries.find { |d| doc_header.id.to_s == d.id.to_s && doc_header.type == d.type && doc_header.routing == d.routing } + doc = entries.find { |d| d.eql?(doc_header, match_lazy_doc_header: true) } doc&.mutate(attr_name) { value } end end @@ -262,8 +262,9 @@ def import(*repo_types, context: {}, eager_load_lazy_attributes: false, update_l if lazy_attrs_to_search_preload.any? hits = repo.index.search(query: {ids: {values: entries.map(&:id)} }, _source: lazy_attrs_to_search_preload).response.hits hits.each do |hit| - doc_header = Esse::LazyDocumentHeader.coerce(hit.slice('_id', '_routing')) # TODO Add '_type', when adjusting eql to tread _doc properly - next unless doc_header.valid? + doc_header = Esse::LazyDocumentHeader.coerce(hit.slice('_id', '_routing', '_type')) + next if doc_header.id.nil? + hit.dig('_source')&.each do |attr_name, attr_value| real_attr_name = repo.lazy_document_attribute_names(attr_name).first preload_search_result[real_attr_name][doc_header] = attr_value @@ -271,7 +272,7 @@ def import(*repo_types, context: {}, eager_load_lazy_attributes: false, update_l end preload_search_result.each do |attr_name, values| values.each do |doc_header, value| - doc = entries.find { |d| doc_header.id.to_s == d.id.to_s && doc_header.type == d.type && doc_header.routing == d.routing } + doc = entries.find { |d| d.eql?(doc_header, match_lazy_doc_header: true) } doc&.mutate(attr_name) { value } end end @@ -282,7 +283,7 @@ def import(*repo_types, context: {}, eager_load_lazy_attributes: false, update_l lazy_attrs_to_update_after.each do |attr_name| preloaded_ids = preload_search_result[attr_name].keys filtered_docs = entries.reject do |doc| - doc.ignore_on_index? || preloaded_ids.any? { |d| d.id.to_s == doc.id.to_s && d.type == doc.type && d.routing == doc.routing } + doc.ignore_on_index? || preloaded_ids.any? { |d| doc.eql?(d, match_lazy_doc_header: true) } end next if filtered_docs.empty? diff --git a/lib/esse/index/object_document_mapper.rb b/lib/esse/index/object_document_mapper.rb index 933f592..dfcc6e5 100644 --- a/lib/esse/index/object_document_mapper.rb +++ b/lib/esse/index/object_document_mapper.rb @@ -24,7 +24,7 @@ def each_serialized_batch(repo_name = nil, **kwargs, &block) # @return [Enumerator] All serialized entries def documents(repo_name = nil, **kwargs) Enumerator.new do |yielder| - each_serialized_batch(repo_name, **kwargs) do |documents, **_collection_kargs| + each_serialized_batch(repo_name, **kwargs) do |documents| documents.each { |document| yielder.yield(document) } end end diff --git a/lib/esse/lazy_document_header.rb b/lib/esse/lazy_document_header.rb index bfc97a8..7144d3b 100644 --- a/lib/esse/lazy_document_header.rb +++ b/lib/esse/lazy_document_header.rb @@ -2,11 +2,14 @@ module Esse class LazyDocumentHeader + ACCEPTABLE_CLASSES = [Esse::LazyDocumentHeader, Esse::Document].freeze + ACCEPTABLE_DOC_TYPES = [nil, '_doc', 'doc'].freeze + def self.coerce_each(values) arr = [] Esse::ArrayUtils.wrap(values).flatten.map do |value| instance = coerce(value) - arr << instance if instance&.valid? + arr << instance if instance && !instance.id.nil? end arr end @@ -17,7 +20,7 @@ def self.coerce(value) if value.is_a?(Esse::LazyDocumentHeader) value elsif value.is_a?(Esse::Document) - new(**value.options, id: value.id, type: value.type, routing: value.routing) + value elsif value.is_a?(Hash) resp = value.transform_keys do |key| case key @@ -47,10 +50,6 @@ def initialize(id:, type: nil, routing: nil, **extra_attributes) @options = extra_attributes.freeze end - def valid? - !id.nil? - end - def to_h options.merge(_id: id).tap do |hash| hash[:_type] = type if type @@ -58,26 +57,17 @@ def to_h end end - def to_doc(source = {}) - Document.new(self, source: source) + def document_for_partial_update(source) + Esse::DocumentForPartialUpdate.new(self, source: source) end - def eql?(other) - self.class == other.class && id == other.id && type == other.type && routing == other.routing + def eql?(other, **) + ACCEPTABLE_CLASSES.any? { |klass| other.is_a?(klass) } && + id.to_s == other.id.to_s && + routing == other.routing && + ((ACCEPTABLE_DOC_TYPES.include?(type) && ACCEPTABLE_DOC_TYPES.include?(other.type)) || type == other.type) end alias_method :==, :eql? - - class Document < Esse::Document - extend Forwardable - - def_delegators :object, :id, :type, :routing, :options - - attr_reader :source - - def initialize(lazy_header, source: {}) - @source = source - super(lazy_header) - end - end end end + diff --git a/lib/esse/repository/documents.rb b/lib/esse/repository/documents.rb index 0d2a7d6..69e4f3b 100644 --- a/lib/esse/repository/documents.rb +++ b/lib/esse/repository/documents.rb @@ -16,7 +16,7 @@ def update_documents_attribute(name, ids_or_doc_headers = [], kwargs = {}) def documents_for_lazy_attribute(name, ids_or_doc_headers) retrieve_lazy_attribute_values(name, ids_or_doc_headers).map do |doc_header, datum| - doc_header.to_doc(name => datum) + doc_header.document_for_partial_update(name => datum) end end @@ -36,11 +36,10 @@ def retrieve_lazy_attribute_values(name, ids_or_doc_headers) return [] unless result.is_a?(Hash) result.each_with_object({}) do |(key, value), memo| - if key.is_a?(LazyDocumentHeader) && (doc = docs.find { |d| d == key || d.id == key.id }) - memo[doc] = value - elsif (doc = docs.find { |d| d.id == key }) - memo[doc] = value - end + val = docs.find { |doc| doc.eql?(key, match_lazy_doc_header: true) || doc.id == key } + next unless val + + memo[val] = value end end end diff --git a/lib/esse/repository/object_document_mapper.rb b/lib/esse/repository/object_document_mapper.rb index d4f5d95..237b52d 100644 --- a/lib/esse/repository/object_document_mapper.rb +++ b/lib/esse/repository/object_document_mapper.rb @@ -92,13 +92,13 @@ def each_serialized_batch(lazy_attributes: false, **kwargs) attrs = lazy_attributes.is_a?(Array) ? lazy_attributes : lazy_document_attribute_names(lazy_attributes) attrs.each do |attr_name| retrieve_lazy_attribute_values(attr_name, entries).each do |doc_header, value| - doc = entries.find { |d| doc_header.id.to_s == d.id.to_s && doc_header.type == d.type && doc_header.routing == d.routing } + doc = entries.find { |d| d.eql?(doc_header, match_lazy_doc_header: true) } doc&.mutate(attr_name) { value } end end end - yield entries, **collection_context + yield entries end end @@ -110,7 +110,7 @@ def each_serialized_batch(lazy_attributes: false, **kwargs) # @return [Enumerator] All serialized entries def documents(**kwargs) Enumerator.new do |yielder| - each_serialized_batch(**kwargs) do |docs, **_collection_kargs| + each_serialized_batch(**kwargs) do |docs| docs.each { |document| yielder.yield(document) } end end diff --git a/spec/esse/document_for_partial_update_spec.rb b/spec/esse/document_for_partial_update_spec.rb new file mode 100644 index 0000000..1714b0c --- /dev/null +++ b/spec/esse/document_for_partial_update_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +# rubocop:disable RSpec/VerifiedDoubles +RSpec.describe Esse::DocumentForPartialUpdate do + let(:document) { described_class.new(obj, source: source) } + let(:obj) { double(id: 1) } + let(:source) { { foo: :bar } } + + describe '#object' do + subject { document.object } + + it { is_expected.to be obj } + end + + describe '#id' do + subject { document.id } + + it { is_expected.to eq 1 } + end + + describe '#type' do + subject { document.type } + + let(:obj) { double(id: 1, type: 'foo', source: source) } + + it { is_expected.to eq 'foo' } + end + + describe '#routing' do + subject { document.routing } + + let(:obj) { double(id: 1, routing: 'foo', source: source) } + + it { is_expected.to eq 'foo' } + end + + describe '#source' do + subject { document.source } + + let(:obj) { double(id: 1, source: { original: 'source' }) } + + it { is_expected.to eq source } + end +end diff --git a/spec/esse/lazzy_document_header_spec.rb b/spec/esse/lazzy_document_header_spec.rb index f710a53..6e1d628 100644 --- a/spec/esse/lazzy_document_header_spec.rb +++ b/spec/esse/lazzy_document_header_spec.rb @@ -7,22 +7,6 @@ let(:object) { { id: nil } } let(:options) { {} } - describe '#valid?' do - it { expect(doc).to respond_to :valid? } - - it 'returns false' do - expect(doc.valid?).to be_falsey - end - - context 'when id is present' do - let(:object) { { id: 1 } } - - it 'returns true' do - expect(doc.valid?).to be_truthy - end - end - end - describe '#id' do it { expect(doc).to respond_to :id } @@ -118,7 +102,7 @@ let(:object) { Esse::HashDocument.new(_id: 1) } it 'returns a LazyDocumentHeader instance' do - expect(described_class.coerce(object)).to be_a(described_class) + expect(described_class.coerce(object)).to be(object) end end @@ -161,7 +145,7 @@ def id it 'returns a LazyDocumentHeader instance with the proper id' do instance = described_class.coerce(object) - expect(instance).to be_a(described_class) + expect(instance).to be(instance) expect(instance.id).to eq(2) end end @@ -194,40 +178,40 @@ def id expect(described_class.coerce_each([[{_id: 1}], {_id: 2}]).size).to eq(2) end - it 'coerces a list of Esse::Document instances' do + it 'return same instances when the given argument is already a Esse::Document' do list = [Esse::HashDocument.new(_id: 1), Class.new(Esse::HashDocument).new(_id: 2)] - expect(described_class.coerce_each(list)).to all(be_a(described_class)) + expect(described_class.coerce_each(list)).to all(be_a(Esse::HashDocument)) end end - describe '#to_doc' do + describe '#document_for_partial_update' do let(:options) { { admin: true } } let(:object) { { id: 1, routing: 'il', type: 'state' } } - it { expect(doc).to respond_to :to_doc } + it { expect(doc).to respond_to :document_for_partial_update } it 'returns a Esse::Document instance' do - expect(doc.to_doc).to be_a(Esse::Document) + expect(doc.document_for_partial_update({})).to be_a(Esse::DocumentForPartialUpdate) end it 'returns a Esse::Document instance with the id' do - expect(doc.to_doc.id).to eq(1) + expect(doc.document_for_partial_update({}).id).to eq(1) end it 'returns a Esse::Document instance routing' do - expect(doc.to_doc.routing).to eq('il') + expect(doc.document_for_partial_update({}).routing).to eq('il') end it 'returns a Esse::Document instance with the type' do - expect(doc.to_doc.type).to eq('state') + expect(doc.document_for_partial_update({}).type).to eq('state') end it 'returns a Esse::Document instance with the options' do - expect(doc.to_doc.options).to eq(admin: true) + expect(doc.document_for_partial_update({}).options).to eq(admin: true) end it 'returns a Esse::Document instance with the object as source and the given source' do - new_doc = doc.to_doc(foo: 'bar') + new_doc = doc.document_for_partial_update(foo: 'bar') expect(new_doc.source).to eq(foo: 'bar') expect(new_doc.object).to eq(doc) expect(new_doc.options).to eq(admin: true) @@ -249,4 +233,132 @@ def id end end end + + describe '#eql?' do + specify do + same = described_class.new(id: 1) + diff = described_class.new(id: 2) + expect(described_class.new(id: 1)).to eq(same) + expect(described_class.new(id: 1)).not_to eq(diff) + end + + specify do + same = described_class.new(id: 1) + diff = described_class.new(id: 2) + expect(described_class.new(id: '1')).to eq(same) + end + + specify do + same = described_class.new(id: 1, type: 'foo') + diff = described_class.new(id: 1, type: 'bar') + expect(described_class.new(id: 1, type: 'foo')).to eq(same) + expect(described_class.new(id: 1, type: 'foo')).not_to eq(diff) + end + + specify do + same = described_class.new(id: 1, routing: 'foo') + diff = described_class.new(id: 1, routing: 'bar') + expect(described_class.new(id: 1, routing: 'foo')).to eq(same) + expect(described_class.new(id: 1, routing: 'foo')).not_to eq(diff) + end + + specify do + same = described_class.new(id: 1, type: 'foo', routing: 'bar') + diff = described_class.new(id: 1, type: 'bar', routing: 'foo') + expect(described_class.new(id: 1, type: 'foo', routing: 'bar')).to eq(same) + expect(described_class.new(id: 1, type: 'foo', routing: 'bar')).not_to eq(diff) + end + + context 'when comparing doc type' do + specify do + expected = described_class.new(id: 1, type: '_doc') + expect(described_class.new(id: 1, type: '_doc')).to eq(expected) + end + + specify do + expected = described_class.new(id: 1, type: '_doc') + expect(described_class.new(id: 1, type: 'doc')).to eq(expected) + end + + specify do + expected = described_class.new(id: 1, type: '_doc') + expect(described_class.new(id: 1, type: nil)).to eq(expected) + end + + specify do + expected = described_class.new(id: 1, type: nil) + expect(described_class.new(id: 1, type: '_doc')).to eq(expected) + end + + specify do + expected = described_class.new(id: 1, type: nil) + expect(described_class.new(id: 1, type: 'doc')).to eq(expected) + end + end + + context 'when comparing with a Esse::Document' do + specify do + header = described_class.new(id: 1) + doc = Esse::HashDocument.new(_id: 1) + expect(header).to eq(doc) + expect(doc.eql?(header)).to eq(false) + expect(doc.eql?(header, match_lazy_doc_header: true)).to eq(true) + end + + specify do + header = described_class.new(id: 1) + doc = Esse::HashDocument.new(_id: 2) + expect(header).not_to eq(doc) + expect(doc.eql?(header)).to eq(false) + expect(doc.eql?(header, match_lazy_doc_header: true)).to eq(false) + end + + specify do + header = described_class.new(id: 1, type: '_doc') + doc = Esse::HashDocument.new(_id: 1) + expect(header).to eq(doc) + expect(doc.eql?(header)).to eq(false) + expect(doc.eql?(header, match_lazy_doc_header: true)).to eq(true) + end + + specify do + header = described_class.new(id: 1) + doc = Esse::HashDocument.new(_id: 1, _type: '_doc') + expect(header).to eq(doc) + expect(doc.eql?(header)).to eq(false) + expect(doc.eql?(header, match_lazy_doc_header: true)).to eq(true) + end + + specify do + header = described_class.new(id: 1, type: '_doc') + doc = Esse::HashDocument.new(_id: 1, _type: 'foo') + expect(header).not_to eq(doc) + expect(doc.eql?(header)).to eq(false) + expect(doc.eql?(header, match_lazy_doc_header: true)).to eq(false) + end + + specify do + header = described_class.new(id: 1, routing: 'il') + doc = Esse::HashDocument.new(_id: 1, _routing: 'il') + expect(header).to eq(doc) + expect(doc.eql?(header)).to eq(false) + expect(doc.eql?(header, match_lazy_doc_header: true)).to eq(true) + end + + specify do + header = described_class.new(id: 1, routing: 'il') + doc = Esse::HashDocument.new(_id: 1, _routing: 'fl') + expect(header).not_to eq(doc) + expect(doc.eql?(header)).to eq(false) + end + + specify do + header = described_class.new(id: 1, extra: 'il') + doc = Esse::HashDocument.new(_id: 1, extra: 'fl') + expect(header).to eq(doc) + expect(doc.eql?(header)).to eq(false) + expect(doc.eql?(header, match_lazy_doc_header: true)).to eq(true) + end + end + end end diff --git a/spec/esse/repository/lazy_document_spec.rb b/spec/esse/repository/lazy_document_spec.rb index a9a8675..bd3b600 100644 --- a/spec/esse/repository/lazy_document_spec.rb +++ b/spec/esse/repository/lazy_document_spec.rb @@ -90,7 +90,7 @@ it 'returns an array of documents that match with the provided ids' do docs = repo.documents_for_lazy_attribute(:city_names, '2') expect(docs).to eq([ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London') ]) end @@ -98,14 +98,14 @@ header = Esse::LazyDocumentHeader.coerce(id: '2') docs = repo.documents_for_lazy_attribute(:city_names, header) expect(docs).to eq([ - Esse::LazyDocumentHeader::Document.new(header, source: { city_names: 'London' }) + Esse::DocumentForPartialUpdate.new(header, source: { city_names: 'London' }) ]) end it 'returns an array of documents that match with the provided single hash' do docs = repo.documents_for_lazy_attribute(:city_names, {id: '2', admin: true}) expect(docs).to eq([ - Esse::LazyDocumentHeader.new(id: '2', admin: true).to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2', admin: true).document_for_partial_update(city_names: 'London') ]) end end @@ -133,21 +133,21 @@ it 'returns an array of documents that match with the provided ids' do docs = repo.documents_for_lazy_attribute(:city_names, '2') expect(docs).to eq([ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London') ]) end it 'returns an array of documents that match with the provided LazyDocumentHeader' do docs = repo.documents_for_lazy_attribute(:city_names, Esse::LazyDocumentHeader.coerce(id: '2')) expect(docs).to eq([ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London') ]) end it 'do not include duplicate documents' do docs = repo.documents_for_lazy_attribute(:city_names, ['2', '2', Esse::LazyDocumentHeader.coerce(id: '2')]) expect(docs).to eq([ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London') ]) end end @@ -169,9 +169,9 @@ it 'returns an array of documents that match with the provided ids' do docs = repo.documents_for_lazy_attribute(:city_names, ['2', '3', '4']) expect(docs).to eq([ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London'), - Esse::LazyDocumentHeader.new(id: '3').to_doc(city_names: nil), - Esse::LazyDocumentHeader.new(id: '4').to_doc(city_names: ''), + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London'), + Esse::LazyDocumentHeader.new(id: '3').document_for_partial_update(city_names: nil), + Esse::LazyDocumentHeader.new(id: '4').document_for_partial_update(city_names: ''), ]) end end @@ -202,7 +202,7 @@ it 'updates the documents' do expect(repo.index).to receive(:bulk).with( update: [ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London') ] ) repo.update_documents_attribute(:city_names, '2') @@ -212,7 +212,7 @@ header = Esse::LazyDocumentHeader.coerce(id: '2') expect(repo.index).to receive(:bulk).with( update: [ - Esse::LazyDocumentHeader::Document.new(header, source: { city_names: 'London' }) + Esse::DocumentForPartialUpdate.new(header, source: { city_names: 'London' }) ] ) repo.update_documents_attribute(:city_names, header) @@ -221,7 +221,7 @@ it 'updates the documents when passing a single hash' do expect(repo.index).to receive(:bulk).with( update: [ - Esse::LazyDocumentHeader.new(id: '2', admin: true).to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2', admin: true).document_for_partial_update(city_names: 'London') ] ) repo.update_documents_attribute(:city_names, {id: '2', admin: true}) @@ -230,7 +230,7 @@ it 'updates the documents when passing an array of ids' do expect(repo.index).to receive(:bulk).with( update: [ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London') ] ) repo.update_documents_attribute(:city_names, ['2']) @@ -240,7 +240,7 @@ header = Esse::LazyDocumentHeader.coerce(id: '2') expect(repo.index).to receive(:bulk).with( update: [ - Esse::LazyDocumentHeader::Document.new(header, source: { city_names: 'London' }) + Esse::DocumentForPartialUpdate.new(header, source: { city_names: 'London' }) ] ) repo.update_documents_attribute(:city_names, [header]) @@ -249,7 +249,7 @@ it 'updates the documents when passing an array of hashes' do expect(repo.index).to receive(:bulk).with( update: [ - Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London') + Esse::LazyDocumentHeader.new(id: '2').document_for_partial_update(city_names: 'London') ] ) repo.update_documents_attribute(:city_names, [{id: '2', admin: true}])