Index definition trickery and sphinx.yml

12 views
Skip to first unread message

mpokress

unread,
Jan 5, 2011, 3:14:04 PM1/5/11
to Thinking Sphinx
Good afternoon-

I am working on a distributed TS implementation which is working quite
well. When I get through a few more steps I want to write this up,
because I am blown away with how well Sphinx actually supports
distributed search.

My question is this, in order to get Sphinx to not have ID collisions
if it searches across multiple indexes some SQL tricks need to be
performed in $RAILS_ENV.sphinx.conf file. This hack is from the
sphinx forums:

On Node 1:

sql_query = SELECT "assets"."id" * 1 + 0... (this is the default
generated by rake ts:conf/rake ts:in)

change to:

sql_query = SELECT "assets"."id" * 10 + 1...

On Node 2:

sql_query = SELECT "assets"."id" * 1 + 0... (this is the default
generated by rake ts:conf/rake ts:in)

change to:

sql_query = SELECT "assets"."id" * 10 + 2...

The net result of this is that all IDs returned by the distributed
search can be related to the node based on the value of the least
significant digit. This works, I have a prototype using straight
Riddle that gets the appropriate results and can get to the correct
ActiveRecord object on the correct node. Very cool stuff.

What worries me is the possibility of rake ts:in trampling the changes
to $RAILS_ENV.sphinx.conf. Is there a syntax that can be used in the
define_index block within the model? What about in sphinx.yml?

Best,

Matt

Pat Allan

unread,
Jan 5, 2011, 9:58:14 PM1/5/11
to thinkin...@googlegroups.com
Hi Matt

There's nothing in Thinking Sphinx for customising the offset for document ids, nor selectively overwriting the configuration file. It's pretty much all-or-nothing at this point.

So, I'd recommend you use rake ts:reindex, which only indexes, and doesn't overwrite the configuration file. And if you want to patch to allow for custom offsets, I'd definitely be interested in seeing your approach. And am especially looking forward to your writeup of how you manage a distributed search setup.

Cheers

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>

Reply all
Reply to author
Forward
0 new messages