Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior of index! with STI #394

Open
matteodepalo opened this issue Nov 26, 2020 · 0 comments
Open

Unexpected behavior of index! with STI #394

matteodepalo opened this issue Nov 26, 2020 · 0 comments

Comments

@matteodepalo
Copy link
Contributor

Description

Calling index! in a model that uses STI creates a separate index with that model's name as its name.

Steps to reproduce

My current setup has a parent model with a few sub-classes:

class Content < ActiveRecord::Base
   include AlgoliaSearch
   
   algoliasearch { ... }
end

class Post < Content
end

When calling Content.find(id).index! or Post.find(id).index! the current implementation creates a new index named Post instead of reusing the parent index Content. I've fixed this by specifying the index name:

class Content < ActiveRecord::Base
   include AlgoliaSearch
   
   algoliasearch index_name: "Content" { ... }
end

I'm also aware I can do Content.where(id: id).reindex! and this will work.

If this is expected behavior then would it be worth mentioning it in the docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant