diff --git a/Gemfile.lock b/Gemfile.lock index 7ba0b52..ccdaf44 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/marcosgz/esse.git - revision: 56e9a200a1d88c2163989854e8cf2fca952503a0 + revision: 8fd302274e9c9c0dcdeec7b8f6ffafc05234014b branch: main specs: esse (0.4.0.rc1) diff --git a/lib/esse/async_indexing/actions/bulk_delete.rb b/lib/esse/async_indexing/actions/bulk_delete.rb index d794b04..7b92eb6 100644 --- a/lib/esse/async_indexing/actions/bulk_delete.rb +++ b/lib/esse/async_indexing/actions/bulk_delete.rb @@ -8,7 +8,7 @@ def self.call(index_class_name, repo_name, ids, options = {}) index_class, _repo_class = CoerceIndexRepository.call(index_class_name, repo_name) bulk_opts = Esse::HashUtils.deep_transform_keys(options, &:to_sym) - index_class.bulk(**bulk_opts, delete: docs.map(&:to_doc)) + index_class.bulk(**bulk_opts, delete: docs.map(&:doc_header)) docs.size end end diff --git a/lib/esse/async_indexing/actions/bulk_update.rb b/lib/esse/async_indexing/actions/bulk_update.rb index 98f0b63..404261f 100644 --- a/lib/esse/async_indexing/actions/bulk_update.rb +++ b/lib/esse/async_indexing/actions/bulk_update.rb @@ -2,7 +2,6 @@ module Esse::AsyncIndexing::Actions class BulkUpdate - DOC_ARGS = %i[lazy_attributes context] def self.call(index_class_name, repo_name, ids, options = {}) ids = Array(ids) @@ -14,8 +13,11 @@ def self.call(index_class_name, repo_name, ids, options = {}) if (context = bulk_opts.delete(:context)) find_opts.merge!(context) end - if (lazy_attributes = bulk_opts.delete(:lazy_attributes)) - find_opts[:lazy_attributes] = lazy_attributes + if (val = bulk_opts.delete(:eager_load_lazy_attributes)) + find_opts[:eager_load_lazy_attributes] = val + end + if (val = bulk_opts.delete(:preload_lazy_attributes)) + find_opts[:preload_lazy_attributes] = val end find_opts[:id] = ids diff --git a/lib/esse/async_indexing/actions/delete_document.rb b/lib/esse/async_indexing/actions/delete_document.rb index 3a37b08..2c456dd 100644 --- a/lib/esse/async_indexing/actions/delete_document.rb +++ b/lib/esse/async_indexing/actions/delete_document.rb @@ -2,7 +2,7 @@ module Esse::AsyncIndexing::Actions class DeleteDocument - DOC_ARGS = %i[lazy_attributes] + DOC_ARGS = %i[eager_load_lazy_attributes preload_lazy_attributes] def self.call(index_class_name, repo_name, document_id, options = {}) index_class, _repo_class = CoerceIndexRepository.call(index_class_name, repo_name) diff --git a/lib/esse/async_indexing/actions/index_document.rb b/lib/esse/async_indexing/actions/index_document.rb index 5733f5f..da462f1 100644 --- a/lib/esse/async_indexing/actions/index_document.rb +++ b/lib/esse/async_indexing/actions/index_document.rb @@ -2,7 +2,7 @@ module Esse::AsyncIndexing::Actions class IndexDocument - DOC_ARGS = %i[lazy_attributes] + DOC_ARGS = %i[eager_load_lazy_attributes preload_lazy_attributes] def self.call(index_class_name, repo_name, document_id, options = {}) index_class, repo_class = CoerceIndexRepository.call(index_class_name, repo_name) diff --git a/lib/esse/async_indexing/actions/update_document.rb b/lib/esse/async_indexing/actions/update_document.rb index 7c1d112..8cca56b 100644 --- a/lib/esse/async_indexing/actions/update_document.rb +++ b/lib/esse/async_indexing/actions/update_document.rb @@ -2,7 +2,7 @@ module Esse::AsyncIndexing::Actions class UpdateDocument - DOC_ARGS = %i[lazy_attributes] + DOC_ARGS = %i[eager_load_lazy_attributes preload_lazy_attributes] def self.call(index_class_name, repo_name, document_id, options = {}) index_class, repo_class = CoerceIndexRepository.call(index_class_name, repo_name) diff --git a/lib/esse/async_indexing/actions/upsert_document.rb b/lib/esse/async_indexing/actions/upsert_document.rb index 7471407..82df1db 100644 --- a/lib/esse/async_indexing/actions/upsert_document.rb +++ b/lib/esse/async_indexing/actions/upsert_document.rb @@ -2,8 +2,7 @@ module Esse::AsyncIndexing::Actions class UpsertDocument - DOC_ARGS = %i[lazy_attributes] - # OPERATIONS = %w[index update delete] + DOC_ARGS = %i[eager_load_lazy_attributes preload_lazy_attributes] def self.call(index_class_name, repo_name, document_id, operation = "index", options = {}) case operation diff --git a/spec/esse/async_indexing/actions/bulk_update_spec.rb b/spec/esse/async_indexing/actions/bulk_update_spec.rb index 3d1e840..c5eae6c 100644 --- a/spec/esse/async_indexing/actions/bulk_update_spec.rb +++ b/spec/esse/async_indexing/actions/bulk_update_spec.rb @@ -55,7 +55,7 @@ {update: {_id: 1, data: {doc: {name: "City 1"}}}} ] ).and_return("items" => [{}]) - expect(described_class.call("GeosIndex", "city", [1], lazy_attributes: false)).to eq(1) + expect(described_class.call("GeosIndex", "city", [1], eager_load_lazy_attributes: false)).to eq(1) end it "updates all documents with eager loading lazy attributes" do @@ -65,7 +65,7 @@ {update: {_id: 1, data: {doc: {name: "City 1", total_venues: 10}}}} ] ).and_return("items" => [{}]) - expect(described_class.call("GeosIndex", "city", [1], lazy_attributes: true)).to eq(1) + expect(described_class.call("GeosIndex", "city", [1], eager_load_lazy_attributes: true)).to eq(1) end end end diff --git a/spec/esse/async_indexing/actions/delete_document_spec.rb b/spec/esse/async_indexing/actions/delete_document_spec.rb index d4d36dd..9aa26ee 100644 --- a/spec/esse/async_indexing/actions/delete_document_spec.rb +++ b/spec/esse/async_indexing/actions/delete_document_spec.rb @@ -31,7 +31,7 @@ refresh: true ).and_return("result" => "deleted") - expect(described_class.call("VenuesIndex", "venue", hotel[:id], lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:deleted) + expect(described_class.call("VenuesIndex", "venue", hotel[:id], eager_load_lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:deleted) end end end diff --git a/spec/esse/async_indexing/actions/index_document_spec.rb b/spec/esse/async_indexing/actions/index_document_spec.rb index 32ba1e8..0b3d3c2 100644 --- a/spec/esse/async_indexing/actions/index_document_spec.rb +++ b/spec/esse/async_indexing/actions/index_document_spec.rb @@ -31,7 +31,7 @@ refresh: true ).and_return("result" => "created", "_id" => hotel[:id]) - expect(described_class.call("VenuesIndex", "venue", hotel[:id], lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) + expect(described_class.call("VenuesIndex", "venue", hotel[:id], eager_load_lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) end it "does not send the :index request if the document is not found" do diff --git a/spec/esse/async_indexing/actions/update_document_spec.rb b/spec/esse/async_indexing/actions/update_document_spec.rb index 10418e3..cd0d22b 100644 --- a/spec/esse/async_indexing/actions/update_document_spec.rb +++ b/spec/esse/async_indexing/actions/update_document_spec.rb @@ -31,7 +31,7 @@ refresh: true ).and_return("result" => "updated", "_id" => hotel[:id]) - expect(described_class.call("VenuesIndex", "venue", hotel[:id], lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) + expect(described_class.call("VenuesIndex", "venue", hotel[:id], eager_load_lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) end it "does not send a update request if the document is not found" do diff --git a/spec/esse/async_indexing/actions/upsert_document_spec.rb b/spec/esse/async_indexing/actions/upsert_document_spec.rb index 9b5dcb2..967d7bd 100644 --- a/spec/esse/async_indexing/actions/upsert_document_spec.rb +++ b/spec/esse/async_indexing/actions/upsert_document_spec.rb @@ -42,7 +42,7 @@ refresh: true ).and_return("result" => "created", "_id" => hotel[:id]) - expect(described_class.call("VenuesIndex", "venue", hotel[:id], "index", lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) + expect(described_class.call("VenuesIndex", "venue", hotel[:id], "index", eager_load_lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) end end @@ -67,7 +67,7 @@ refresh: true ).and_return("result" => "deleted") - expect(described_class.call("VenuesIndex", "venue", hotel[:id], "delete", lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:deleted) + expect(described_class.call("VenuesIndex", "venue", hotel[:id], "delete", eager_load_lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:deleted) end end @@ -102,7 +102,7 @@ refresh: true ).and_return("result" => "updated", "_id" => hotel[:id]) - expect(described_class.call("VenuesIndex", "venue", hotel[:id], "update", lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) + expect(described_class.call("VenuesIndex", "venue", hotel[:id], "update", eager_load_lazy_attributes: false, refresh: true, suffix: "2024")).to eq(:indexed) end end