0
votes

I've been having a problem with Thinking Sphinx's query generation. I would input a query like '"jack | "the bean stalk" | jill | jeffrey", and instead of the expected fast index loop, I get the slow SQL query:

SELECT table.id, table.FullName FROM table WHERE (LOWER(table.FullName) LIKE '%jack or \"the bean stalk\" or jill or jeffrey%') ORDER BY table.FullName ASC LIMIT 10

This query is strange for a number of reasons. First, instead of a boolean lookup, I get a wildcard lookup of a misceginated version of the query. Second, it is searching ordered by FullName, when I requested some other field to order by (LastName).

I know that Thinking Sphinx will bypass its index and drop into native SQL queries when sorting against a column that was not specified :sortable => true, and it will do so on columns that are not strings. However neither is the case here.

Why is it dropping into native SQL?

1

1 Answers

0
votes

I am absolutely certain that Thinking Sphinx is not making that SQL query. I wonder: do you have other gems (in your Gemfile, or perhaps as dependencies of other gems?) that add search functionality that may be getting in the way? For example, I know activeadmin has a dependency on meta_search.

One possible way around this is to have activeadmin (or whatever the gem that's causing this problem is) listed before thinking-sphinx in your Gemfile (and thus, TS gets loaded after, and inserts the search method that you're expecting).