-
Notifications
You must be signed in to change notification settings - Fork 6
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
Clarified usage of custom queries, added exclude, made internal methods private. #17
Conversation
76d0de8
to
60c8445
Compare
params[:indexed_fields].each do |field, opts| | ||
must term: { field => params[field] } if opts[:filter] && params[field] | ||
end | ||
def add_indexed_fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_filters
is still a more accurate name for this method - it adds filters to the query, not just any indexed fields. the filters are sourced from the list of indexed_fields
but we are not simply adding indexed fields to the query, filters is a more precise term.
this is great - you're quite right, i'm not sure of course, you might want to only go down the 'replace the initializer' route for all customization, but i think just overriding the core query body without worrying about aggregations, sorts, etc is a common use case. |
I've renamed the method back to Generally I feel pretty strongly not to customize methods like Plus, when you override these methods you're potentially breaking what you intended to implement in LMK how you feel about this? |
I agree on not customizing It's true that the order of the BTW I no longer seem to be an owner of the gem for some reason, can you add |
Isn't Added you as owner, sorry about that. Are you going to push 0.2.2 before merging this change? Tell me what you want me to do in here :) |
This PR looks good to me now - going to merge it in. I pushed |
I've pushed |
Thanks @cavvia, I'll work on getting 0.3.0 into Gravity. |
I went down a rabbit hole starting with an untested
exclude
method inEstella::Query
that wasn't used anywhere.First, I made it useful by supporting
exclude
inestella_search
.Then, we document that you can override
query_definition
. But we also have a bunch of methods likeadd_sort
that we don't document but do override in gravity. I propose we kill those by making them private in favor of customizing queries as any Ruby object, in the initializer, as documented in this change.This can be a major version bump, and I can do the gravity change as well.