Search code examples
ruby-on-railselasticsearchtire

How to import index with condition


I have a model named Article in my Rails 3, and I use rake environment tire:import CLASS='Article' FORCE=true to do index. But I only want the articles with field deleted equals to false be indexed. How can I implement it?


Solution

  • You can use the scoped method.

    rake environment tire:import CLASS='Article.scoped(:conditions => {:deleted => false})' FORCE=true
    

    Reference: Answered by karmi @ https://github.com/karmi/tire/issues/458