-
Notifications
You must be signed in to change notification settings - Fork 801
Model.import
not respecting default_scope
#784
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
Comments
default_scope
Model.import
not respecting default_scope
@ctrlaltdylan Would this change in a pull request fix the issue you're having? |
@estolfo honestly I'm not sure, I haven't looked into the internals much of ElasticSearch, I just wanted to at least report the bug. I'm sure you know better than I if it'll fix the issue! |
Also this bug was using the |
ah, ok. Thanks for letting me know. |
@ctrlaltdylan I've opened a pull request to address this. Please test it out and let me know if it works ok for you. Thanks! Update: I've discovered that the |
I'm going to close this issue as I've merged in the pull request #827 testing this issue and showing that the default scope is indeed applied to an import. Please comment or open a new issue if it's not resolved. |
My model has a
default_scope
like this:default_scope { where(status: 1).where.not(user: nil) }
However, during searches Elasticsearch will return
response.records
that do not actually respect the scope:I ran the query without the
WHERE status = 1
and was able to retrieve the records, so that means that Elasticsearch imported records outside of the defineddefault_scope
It seems that during indexing (
Vehicle.import
), thedefault_scope
is not being applied and these records somehow make it into the index.How can we force Elasticsearch to respect the
default_scope
of a model? Or conditionally import records?The text was updated successfully, but these errors were encountered: