Pregunta

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.

¿Fue útil?

Solución

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top