简体   繁体   中英

How to exclude some types from tire results?

Tire.search index do
  query do
    filtered do
      query { string term }
      filter :or, { missing: { field: :group_id } },
                  { terms: { group_id: group_ids } }
      filter :not { type: "Movie" } if current_user.has_not_permission("Movie")
    end
  end
end.results

I would like to exclude all Movie results if user has not permission to movie.

Here is a pretty good answer for authorizing elasticsearch results:

Authorize elasticsearch results with cancan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM