-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow multiple values in the resource-type-id parameter #1221
Conversation
app/models/doi.rb
Outdated
@@ -962,7 +962,7 @@ def self.query(query, options = {}) | |||
minimum_should_match = 0 | |||
|
|||
filter << { terms: { doi: options[:ids].map(&:upcase) } } if options[:ids].present? | |||
filter << { term: { resource_type_id: options[:resource_type_id].underscore.dasherize } } if options[:resource_type_id].present? | |||
filter << { terms: { resource_type_id: options[:resource_type_id].split(",").map(&:underscore).map(&:dasherize) } } if options[:resource_type_id].present? |
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.
Code changes look perfect, can we format it like this,
if options[:resource_type_id].present?
resource_type_ids = options[:resource_type_id]
.split(",")
.map { |id| id.strip.underscore.dasherize }
filter << { terms: { resource_type_id: resource_type_ids } }
end
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.
I've done this, thanks for the suggestion :)
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.
Looks great, thanks for addressing the changes :)
Purpose
We allow querying against multiple values for
resourceType
, but notresourceTypeGeneral
. SinceresourceTypeGeneral
is a controlled list, it seems useful to allow multiple queries in a single API call, as this uses the much more efficientfilter
approach in ES (vs doing?query=types.resourceTypeGeneral:x OR types.resourceTypeGeneral:y
)This PR adds support for multiple values in the
resource_type_id
parameter, which ultimately uses the value fromresourceTypeGeneral
via https://github.com/datacite/lupo/blob/master/app/models/doi.rb#L1232-L1237 and https://github.com/datacite/lupo/blob/master/app/models/doi.rb#L2489-L2495closes: Add github issue that originated this PR
Approach
Open Questions and Pre-Merge TODOs
Learning
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Reviewer, please remember our guidelines: