Skip to content

Commit

Permalink
fix: use matching option only when reindex
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Aug 10, 2015
1 parent a41700b commit f770236
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/sphinx/integration/transmitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ 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 индексе
partitions { |i| ThinkingSphinx.update(index.rt_name_w(i), 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) }
Expand Down
4 changes: 2 additions & 2 deletions spec/sphinx/integration/transmitter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down

0 comments on commit f770236

Please sign in to comment.