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

OpenSearch and GraphQL for multiple source filters #534

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

JPrevost
Copy link
Member

@JPrevost JPrevost commented Jul 6, 2022

Why are these changes being introduced:

  • Being able to search multiple source at once is desired

Relevant ticket(s):

How does this address that need:

  • Creates a method to add "OR" filtering in OpenSearch
  • Updates GraphQL to expect source as an array of keywords instead of
    a single string

Document any side effects to this change:

  • GraphQL previously expected Source as a single string and now expects
    an array of strings. As V2 is not yet launched, this isn't a concern
    for V2, but may require changes for V1 consumers including Bento which
    filters to just ArchivesSpace.

Developer

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod
  • ANDI or Wave has been run in accordance to
    our guide and
    all issues introduced by these changes have been resolved or opened as new
    issues (link to those issues in the Pull Request details above)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Changes GraphQL Schema

YES, in a way that might cause issues when we enable v2 (haven't confirmed fully yet)

Requires database migrations?

NO

Includes new or updated dependencies?

NO

@mitlib mitlib temporarily deployed to timdex-pr-534 July 6, 2022 16:09 Inactive
@jazairi jazairi self-assigned this Jul 7, 2022
Copy link
Contributor

@jazairi jazairi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a comment needs to be updated in one of the tests, but otherwise this is looking great and seems to be working as expected. :shipit:

Good call-out about how this might affect V1 consumers. I think we can add that to the checklist before we deploy to prod. Fwiw, I seem to be able to filter by source using the V1 endpoint on this PR, but I'd want to do a little more testing to confirm that.

test 'graphqlv2 filter multiple sources' do
VCR.use_cassette('graphql v2 filter multiple sources') do

# no filters return 4 sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this asserted anywhere? I don't see that count confirmed in the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh, left that comment in and refactored the test to not be based on a specific number and instead just "there should be more than the filtered count" to make this less fragile. I'll adjust or remove the comments.

Copy link
Contributor

@jazairi jazairi Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that explains it. Yeah, I agree that this testing approach is more robust.

json = JSON.parse(response.body)
initial_source_array = json['data']['search']['aggregations']['source']

# filtering to 2 sources returns 2 sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be filtering to 1 source returns 1 source?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. 🙈

@JPrevost JPrevost temporarily deployed to timdex-pr-534 July 7, 2022 18:36 Inactive
@JPrevost JPrevost requested a review from jazairi July 7, 2022 18:36
Why are these changes being introduced:

* Being able to search multiple source at once is desired

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/RDI-170

How does this address that need:

* Creates a method to add "OR" filtering in OpenSearch
* Updates GraphQL to expect source as an array of keywords instead of
  a single string

Document any side effects to this change:

* GraphQL previously expected Source as a single string and now expects
  an array of strings. As V2 is not yet launched, this isn't a concern
  for V2, but may require changes for V1 consumers including Bento which
  filters to just ArchivesSpace.
@JPrevost JPrevost force-pushed the rdi-170-searching-multiple-sources branch from 1bef1e7 to 00a3f15 Compare July 7, 2022 18:46
@JPrevost JPrevost temporarily deployed to timdex-pr-534 July 7, 2022 18:46 Inactive
@JPrevost JPrevost merged commit 99da08a into main Jul 7, 2022
@JPrevost JPrevost deleted the rdi-170-searching-multiple-sources branch July 7, 2022 18:47
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