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

Add support for geobox searches to GraphQL #792

Merged
merged 2 commits into from
Feb 15, 2024
Merged

Add support for geobox searches to GraphQL #792

merged 2 commits into from
Feb 15, 2024

Conversation

matt-bernhardt
Copy link
Member

@matt-bernhardt matt-bernhardt commented Feb 14, 2024

Why are these changes being introduced:

We have enabled searching via a bounding box within OpenSearch, and need to extend that support to GraphQL in order to make it possible in the UI.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/gdt-184

How does this address that need:

This defines a GeoboxType, with four fields: two latitude and two longitude values, each expressed as floats.

Document any side effects to this change:

  • I've tried to write tests to indicate the edges of what is possible - for example showing that you get results back if you provide both a geodistance and geobox (even if they don't result in overlapping regions - it seems like bbox is used in that case).

  • Similarly, I've written a test showing that it is valid to search using either order of the longitude values, because both results are valid - and different - bounding boxes. (If the latitude orders are reversed, the application errors in a way that is not captured via a cassette)

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

Requires database migrations?

NO

Includes new or updated dependencies?

NO

** Why are these changes being introduced:

* We have enabled searching via a bounding box within OpenSearch, and
  need to extend that support to GraphQL in order to make it possible
  in the UI.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/gdt-184

** How does this address that need:

* This defines a GeoboxType, with four fields: two latitude and two
  longitude values, each expressed as floats.

** Document any side effects to this change:

* I've tried to write tests to indicate the edges of what is possible
  - for example showing that you get results back if you provide both
  a geodistance and geobox (even if they don't result in overlapping
  regions - it seems like bbox is used in that case).

* Similarly, I've written a test showing that it is valid to search
  using either order of the longitude values, because both results are
  valid - and different - bounding boxes. (If the latitude orders are
  reversed, the application errors in a way that is not captured via
  a cassette)
Copy link
Member

@JPrevost JPrevost left a comment

Choose a reason for hiding this comment

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

I'd prefer a comment in the tests to be updated to clarify what is going on and how we don't really think people should do that even if we allow it rather than the current comment, but it's not blocking.

end

test 'graphqlv2 geobox search with geodistance search' do
# Should this work? It does.
Copy link
Member

Choose a reason for hiding this comment

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

I think a slightly better comment might point out that we don't intend this to be a feature, but we aren't going to prevent people from doing it maybe? I guess we could suggest in the docs that only one geo query at a time is supported.

From my exploration around this I think it ANDs the results together but our data is difficult to reason with at times as we have a lot of things that show up effectively globally that feel like they shouldn't so it's hard to know if our queries are wonky or the data is wonky. For sure I get a smaller set of results when I search for a geobox around Boston and combine with with a geodistance search around the center of India than either of those searches independently which feels correct (even if some of the results are questionable... like "Rivers of Alaska" I'd expect not to be in that search but it is)

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 updated this code comment - will be merging now. Thanks!

@mitlib mitlib temporarily deployed to timdex-pr-792 February 15, 2024 15:02 Inactive
@matt-bernhardt matt-bernhardt merged commit 66dd37a into main Feb 15, 2024
3 of 4 checks passed
@matt-bernhardt matt-bernhardt deleted the gdt-184 branch February 15, 2024 15:05
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