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

Allow multiple values in the resource-type-id parameter #1221

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

digitaldogsbody
Copy link
Member

Purpose

We allow querying against multiple values for resourceType, but not resourceTypeGeneral. Since resourceTypeGeneral is a controlled list, it seems useful to allow multiple queries in a single API call, as this uses the much more efficient filter 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 from resourceTypeGeneral 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-L2495

closes: 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:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

@digitaldogsbody digitaldogsbody requested a review from a team July 26, 2024 01:04
@@ -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?
Copy link
Contributor

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

Copy link
Member Author

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 :)

@digitaldogsbody digitaldogsbody requested review from a team and ashwinisukale July 26, 2024 10:06
Copy link
Contributor

@ashwinisukale ashwinisukale left a 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 :)

@digitaldogsbody digitaldogsbody merged commit 2ddd224 into master Jul 26, 2024
13 checks passed
@digitaldogsbody digitaldogsbody deleted the allow-multiple-rtids branch July 26, 2024 10:25
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

Successfully merging this pull request may close these issues.

3 participants