Thinking Sphinx not picking up define_index changes?

28 views
Skip to first unread message

David Aronchick

unread,
Dec 28, 2009, 11:18:53 PM12/28/09
to Thinking Sphinx
I've been trying to get Thinking Sphinx for Ruby to handle prefixes
and/or star, and every time i generate a new configuration file, it
seems to ignore it.

Here's the line I added:

define_index do
[... Stuff ...]
set_property :min_prefix_len => 1
end

And then I run:

rake ts:config
rake ts:in
rake ts:run

And nothing new. I keep checking the config file, and it never changes
due to this. I even manually go in and change the file, and then in is
replaced with a file without anything relating to min_prefix. Any
thoughts?

-----

As an aside, what version of thinking sphinx now allows multiple
indexes against a single table? I'd like to have one index with
min_prefix_len on, and one without.

Pat Allan

unread,
Dec 28, 2009, 11:38:08 PM12/28/09
to thinkin...@googlegroups.com
Hi David

What version of TS are you currently using? 1.3.6 was when multiple index support was added, but I'd recommend using the latest (1.3.14). Also, what's the full contents of your define_index block?

--
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.
>
>

David Aronchick

unread,
Dec 29, 2009, 1:14:57 PM12/29/09
to Thinking Sphinx
Hi--

In truth, I'm not sure - the gemspec says 0.9.9, but rake ts:version
fails (Don't know how to build task 'thinking_sphinx:version').

The rest of my define index is very standard:

define_index do
#indexed fields, fields to be added to the full text index
indexes :name, :sortable => true
indexes aliases(:alias), :as => :aliases

#attributes (fields to be sorted by, or grouped by)
has [field names], :as => [aliases] x 20

set_property :min_prefix_len => 1

#used to determine if the index has been rebuilt recently
has "UNIX_TIMESTAMP()", :as => :index_time
end

Pat Allan

unread,
Dec 29, 2009, 7:24:57 PM12/29/09
to thinkin...@googlegroups.com
Hi David

If there's no ts:version task, then I think you're using a really old version of TS. It's definitely worth trying to upgrade, see if that helps matters.

--
Pat

David Aronchick

unread,
Dec 30, 2009, 2:38:28 PM12/30/09
to Thinking Sphinx
Ok, i've upgraded, and now I've added the two index names (index_name
'prefix index') to the define_index statements... here's the response:

ERROR: section 'library_core_0' (type='source') already exists [...]

Pat Allan

unread,
Dec 30, 2009, 7:54:02 PM12/30/09
to thinkin...@googlegroups.com
Hi David

The multiple index support isn't really documented at all... but what you'll need to do is give any additional indexes an explicit name, to avoid collisions:

define_index do
# default
end

define_index 'prefixed_library' do
# additional
end

Hopefully this gets it working.

--
Pat

David Aronchick

unread,
Dec 30, 2009, 11:35:55 PM12/30/09
to Thinking Sphinx
Ok, so far got past the original blocking issue - but now the issue
seems to be specifying the indexing to use ... based on these two
definitions, how do I execute:

Library.search('New York')
Library.search('Ne', :index => 'prefixed_libray')

?

Pat Allan

unread,
Jan 2, 2010, 12:54:54 AM1/2/10
to thinkin...@googlegroups.com
Hi David

If you want to query across two indexes, just do a standard search:

Library.search 'New York'

The :index option will filter on a specific index (multiple ones can be defined in a string, comma-separated).

However, you cannot direct part of a query at a specific index (ie: New York on your core index, Ne on the prefixed one), all at once. The two queries you've specified below should work, though, if you're doing them separately. The only catch is that you may need enable_star set to true and then for the second, use stars/wildcards:

Library.search 'Ne*', :index => 'prefixed_library'

I've not done any thorough testing on whether wildcards are needed to force the prefix/infix matching. Hopefully it's not required, but I've vague memories of it not working for some people.

Hope this is helpful.

--
Pat

David Aronchick

unread,
Jan 8, 2010, 1:10:26 PM1/8/10
to Thinking Sphinx
Just for future reference, here was the answer (posted here as well
http://stackoverflow.com/questions/1972107/thinking-sphinx-not-recognizing-setproperty-minprefixlen):

-Upgrade to more recent version of TS - older versions (<1.3.14) do
not support multiple indexes
-The define index blocks need to be setup like this:

define_index 'library_index' do
[...]
end

define_index 'prefix_library_index' do
[...]


set_property :min_prefix_len => 1
end

-Calling the search function needs to specify the index or it will
search across all indexes -

Library.search(keyword, { index => 'prefix_libary_index', <other
params here> } )


On Jan 1, 9:54 pm, Pat Allan <p...@freelancing-gods.com> wrote:
> Hi David
>

> > For more options, visit this group athttp://groups.google.com/group/thinking-sphinx?hl=en.- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages