Question

Let's assume that we have a table users.

CREATE TABLE users
(
  id    INT,
  guest BOOL,
  name  VARCHAR(255)
)

I would like to index using Thinking Sphinx only records with guest equal to false. At this moment I have:

ThinkingSphinx::Index.define :user, with: :active_record do
  indexes :name
end

Thanks.

Was it helpful?

Solution

Index definitions have a where method to apply conditions to the generated SQL for indices:

ThinkingSphinx::Index.define :user, with: :active_record do
  indexes name

  where "users.guest = FALSE"
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top