raw query via riddle

25 views
Skip to first unread message

J. Garcia

unread,
May 21, 2015, 8:55:22 AM5/21/15
to thinkin...@googlegroups.com
I am using Thinking Sphinx within my rails project and this is fine.
However, I'd like to run an aggregated raw query against the configured sphinx search, which does not return any of the models.

It seems I can do this via Riddle. However, how can I get a client from my current Thinking Sphinx setup?

If that is possible, that is. I prefer to skip config details if I can.

J.




Pat Allan

unread,
May 21, 2015, 9:59:34 AM5/21/15
to thinkin...@googlegroups.com
Hi J

Presuming you’re using Thinking Sphinx v3, you’ve got two options:

* Perform a standard TS search, but use the ‘raw’ middleware set (which doesn’t translate Sphinx results into ActiveRecord objects):

results = Model.search ‘foo’, :middleware => ThinkingSphinx::Middlewares::RAW_ONLY

* Or, construct the SphinxQL queries yourself by hand, and send them through to the underlying connection (essentially, a wrapper around the mysql2 gem):

results = ThinkingSphinx::Connection.take do |connection|
connection.execute “SELECT * FROM foo_core"
end

Cheers


Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to thinking-sphi...@googlegroups.com.
> To post to this group, send email to thinkin...@googlegroups.com.
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.

J. Garcia

unread,
May 21, 2015, 10:20:59 AM5/21/15
to thinkin...@googlegroups.com
Pat,

It works great!
The second is the one I need.

Many thanks for the quick reply.
J.
Reply all
Reply to author
Forward
0 new messages