Namespaced model in thinking_sphinx 3.0.0

116 views
Skip to first unread message

Daly

unread,
Jan 15, 2013, 12:45:49 PM1/15/13
to thinkin...@googlegroups.com
I have a model called Lcbo::Store, after upgrading to version 3.0.0 I can't seem to use sphinx with it anymore. After much tinkering, I've reached the following config:

# app/indices/store_index.rb
ThinkingSphinx::Index.define :"Lcbo::Store", name:"lcbo_store", with: :active_record, delta:false do
  indexes :address
  indexes :intersection
  indexes city.name, as: :city
end

running rake ts:index now runs successfully and generates the proper entry in development.sphinx.conf. Unfortunately, it still fails with an actual search with:

Mysql2::Error (sphinxql: syntax error, unexpected WHERE, expecting IDENT near 'WHERE MATCH('brampto @sphinx_internal_class_name (Lcbo::Store)') AND sphinx_deleted = 0 LIMIT 0, 100; SHOW META'):

What config changes do I need to make to have this work?

Thanks,
Ahmed

Pat Allan

unread,
Jan 15, 2013, 5:59:21 PM1/15/13
to thinkin...@googlegroups.com
Hi Ahmed

Just yesterday I pushed a patch to get searching working on namespaced models - essentially, the class names need to be quoted in the query (@sphinx_internal_class_name ("Lcbo::Store")). So if you grab the latest from the edge branch, you should be good to go.

gem 'thinking-sphinx',
:git => 'git://github.com/pat/thinking-sphinx.git',
:ref => 'bb56c29ea5'

As for index definitions, it's mentioned in the README (but many things are, so you have to know to look for it) - the index reference should be a string, with a slash indicating the namespaced nature of the model:

ThinkingSphinx::Index.define 'lcbo/store', with: :active_record do
#
end

Hope this helps!

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/bVointrCX88J.
> 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.



Ahmed El-Daly

unread,
Jan 15, 2013, 9:07:01 PM1/15/13
to thinkin...@googlegroups.com
Thanks Pat. Works perfectly! :)

---------------------------------------------------------
Ahmed El-Daly
 Chief Guru 
DeveloperGurus Inc.  on budget, on time
T: 416-566-4945  |  developergurus.com

Timo Virkkala

unread,
Jan 16, 2013, 1:59:03 AM1/16/13
to thinkin...@googlegroups.com
Hi Pat,

When I was reading through the README, I thought that that mention of
the namespaced models in index definitions should perhaps be moved
right next to the original mention of how to define indexes. Perhaps
Ahmed's question is proof that it should be moved?

-Timo Virkkala

Pat Allan

unread,
Jan 21, 2013, 7:53:22 AM1/21/13
to thinkin...@googlegroups.com
Thanks Timo, that's a good point - I've just shifted it to be with the rest of the index definition documentation.
Reply all
Reply to author
Forward
0 new messages