Delta indexes in Sphinx

4 views
Skip to first unread message

Srinivasan

unread,
Jul 24, 2008, 10:20:02 AM7/24/08
to Thinking Sphinx
Hi,

Is there a way to configure ThinkingSphinx or Sphinx to force delta-
reindex the left side model of a one-to-one relationship upon a change
in the right side model? For example, lets say we have the following
models:

class Order < ActiveRecord::Base
has_one :invoice
define_index do
indexes invoice.description, :as => "desc"
set_property :delta => true
end
# . . .
end

class Invoice < ActiveRecord::Base
# has the attr "description"
belongs_to :order

# . . .
end


If "an_order.invoice.description" is updated, the changes are not
available in Order.search unless full indexing is done. Can this be
better? And also, how do we deal with has_many-through and habtm
relationships?

Thanks in advance. Specifically, thanks Pat, for the great plugin.

-- Srini

ts

unread,
Jul 24, 2008, 10:50:53 AM7/24/08
to Thinking Sphinx
BTW, I had earlier tried a few things, including Wade's (set :delta in the model to true) and Collcore's ideas (force a save on the AR::B object) discussed on the thread:
http://groups.google.com/group/thinking-sphinx/browse_thread/thread/9a0c26e15ffde65f/4f8c8d9ab1475437.

But none of them seem to be producing the desired outcome. What i see happening is that the AR:B object is getting marked for an index update, and the current call to indexer isn't picking up the change, but the next call to indexer on the model index does it. Am i missing something?

Thanks.

-- Srini

Pat Allan

unread,
Jul 27, 2008, 7:00:22 PM7/27/08
to thinkin...@googlegroups.com
Hi Srini

I'm assuming you're using Rails 2.1 - the problem could be that Rails now doesn't actually run an update call to the database unless data changes.
Have you tried combining both setting delta to true and *then* calling save on it?

Cheers

-- 
Pat

ts

unread,
Jul 28, 2008, 2:48:02 PM7/28/08
to thinkin...@googlegroups.com
On Mon, Jul 28, 2008 at 4:30 AM, Pat Allan <p...@freelancing-gods.com> wrote:
Hi Srini

I'm assuming you're using Rails 2.1 - the problem could be that Rails now doesn't actually run an update call to the database unless data changes.
Have you tried combining both setting delta to true and *then* calling save on it?

Hi Pat

I tried doing that too. What's happening is that the updates are happening regularly. I tried setting the delta to true, and later call save, but the last change is not immediately available. Is there any known time lag between the update and indexer picking up the changes?

Thank you.

-- Srini
 

Pat Allan

unread,
Jul 28, 2008, 2:50:17 PM7/28/08
to thinkin...@googlegroups.com
There shouldn't be - there was in the past, but that's because the delta indexing happened before the transaction was committed to the database.

Are you using explicit transactions?

-- 
Pat

ts

unread,
Jul 28, 2008, 10:19:37 PM7/28/08
to thinkin...@googlegroups.com
On Tue, Jul 29, 2008 at 12:20 AM, Pat Allan <p...@freelancing-gods.com> wrote:
There shouldn't be - there was in the past, but that's because the delta indexing happened before the transaction was committed to the database.

Are you using explicit transactions?

No, i haven't tried that option yet. I'll try it and see if it solves the problem.

Thank you.

Pat Allan

unread,
Jul 28, 2008, 11:10:39 PM7/28/08
to thinkin...@googlegroups.com
Hi Srini

An explicit transaction won't actually help - it would cause the problem you're seeing (at the moment, anyway - I need to get a fix implemented for it).

So we still don't have a solution...

-- 
Pat

Reply all
Reply to author
Forward
0 new messages