makeapp

Joined

10 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Searchick filter with scope

Hi, I still have this problem. When I create a user whose role is not "a" and search, I can get that user. Should I specify where in the search function? But when I explicitly call People.reindex, I can not get that user any more.

This is what I write

People.rb
scope :search_import, ->{where(role:"a")}
def should_index?
  self.search_import
end
def search_data
  {
    username: username,
    description:description,
    role:role,
  }
end

When I search, i use

result=People.search(params[:search], {fields: [role], autocomplete: true, load: false, misspellings: {below: 4}})