Skip to content

Need a non-cached index_scope #995

Description

@codezomb

I may be misunderstanding this, but I wanted to double check.

We have a multi tenant situation. We have index names dynamically set, but we need to have dynamic scopes. From what I'm seeing, index_scope is run once, but then "cached" for subsequent runs.

Example:

DocumentIndex < Chewy::Index
  index_scope Document.where(license_ids: Tenant.current.license_ids)
end
Apartment.tenant_names.each do |tenant|
  DocumentIndex.sync
end

What we end up seeing, is the first sync in the loop has the correct license_ids, but every subsequent query is a cached version of the first query.

Is there a way to ensure in this case that the query is called with the appropriate scope?

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions