Searchkick find entries by boolean field where clause in Rails

Viewed 13

I have troubles querying in searchkick by boolean field only, I have tried many ways to query without luck

I have this model

class User < ApplicationRecord
  searchkick

  # Indexed data
  def search_data
    {
      email: email,
      verified: verified,
      created_at: created_at,
      updated_at: updated_at,
    }
  end
end

I want to return with searchkick all users with verified: true, so I have run User.reindex

Then I have tried this queries:

results = User.search("*", where: { verified: true })
results.response
{"took"=>0, "timed_out"=>false, "_shards"=>{"total"=>1, "successful"=>1, "skipped"=>0, "failed"=>0}, "hits"=>{"total"=>{"value"=>0, "relation"=>"eq"}, "max_score"=>nil, "hits"=>[]}}

# Variations
results = User.search('*', :where=>{:verified=>[true]})
results = User.search('*', :where=>{:verified=>[1]})
results = User.search('*', :where=>{:verified=>["1"]})
results = User.search('*', :where=>{:verified=>["true"]})

I know I have users marked as verified in database but I cannot make it work in searchkick, I am missing something to search by boolean field?

0 Answers
Related