From f7702361da58c404b03b30cf20b5511c7d46ac6e Mon Sep 17 00:00:00 2001 From: bibendi Date: Mon, 10 Aug 2015 18:38:50 +0500 Subject: [PATCH] fix: use matching option only when reindex https://jira.railsc.ru/browse/PC4-15389 --- lib/sphinx/integration/transmitter.rb | 3 ++- spec/sphinx/integration/transmitter_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sphinx/integration/transmitter.rb b/lib/sphinx/integration/transmitter.rb index a588cf4..a56b3d1 100644 --- a/lib/sphinx/integration/transmitter.rb +++ b/lib/sphinx/integration/transmitter.rb @@ -70,6 +70,8 @@ def update(record, data) def update_fields(fields, where) return if write_disabled? + matching = where.delete(:matching) + rt_indexes do |index| if full_reindex? # вначале обновим всё что уже есть в rt индексе @@ -77,7 +79,6 @@ def update_fields(fields, where) # и зареплейсим всё что осталось в core # TODO: implement sphinx transactions - matching = where.delete(:matching) batch_options = {where: where, matching: matching} ThinkingSphinx.find_in_batches(index.core_name, batch_options) do |ids| klass.where(id: ids).each { |record| transmit(index, record) } diff --git a/spec/sphinx/integration/transmitter_spec.rb b/spec/sphinx/integration/transmitter_spec.rb index f44274b..ae373f7 100644 --- a/spec/sphinx/integration/transmitter_spec.rb +++ b/spec/sphinx/integration/transmitter_spec.rb @@ -43,8 +43,8 @@ before { transmitter.stub(:full_reindex? => true) } it do - expect(ThinkingSphinx).to receive(:update).with("model_with_rt_rt0", {field: 123}, id: 1, matching: "@id_idx 1") - expect(ThinkingSphinx).to receive(:update).with("model_with_rt_rt1", {field: 123}, id: 1, matching: "@id_idx 1") + expect(ThinkingSphinx).to receive(:update).with("model_with_rt_rt0", {field: 123}, id: 1) + expect(ThinkingSphinx).to receive(:update).with("model_with_rt_rt1", {field: 123}, id: 1) expect(ThinkingSphinx). to receive(:find_in_batches). with("model_with_rt_core", where: {id: 1}, matching: "@id_idx 1").