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

Return empty results when searching for a nonexistent collection #185

Merged
merged 12 commits into from
Feb 23, 2022

Conversation

marchuffnagle
Copy link
Contributor

Closes #156

Also handles the case where a user searches for multiple collections but some of those collections don't exist. In that case, only results for the collections that exist are returned.

src/lib/api.js Outdated
@@ -377,14 +379,18 @@ const searchItems = async function (collectionId, queryParameters, backend, endp
const ids = extractIds(queryParameters)
const collections = extractCollectionIds(queryParameters)

const collectionsThatExist = Array.isArray(collections)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer if we not have to make the calls to check if the indicies exist first before calling the search. I was thinking the fix would be to add allow_no_indices=true to the call to client.search in es.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 4fd74d3

Base automatically changed from fix-content-types to main February 23, 2022 16:06
...obj,
[key]: parameters[key]
}), {})
const searchParameters = pickBy(parameters)
Copy link
Collaborator

Choose a reason for hiding this comment

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

are parameters that have the value 0 going to be strings here and therefore truthy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The behavior will be the same as it was before, where the value's truthiness is what's evaluated. That being said, we really should start doing some type checking. I've found a number of places where the behavior is going to be suspect.

Copy link
Collaborator

Choose a reason for hiding this comment

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

agree. The last STAC API worked on was in Scala, and about half the code and 3/4 of our time were on validation and error handling.

@marchuffnagle marchuffnagle merged commit 246ff66 into main Feb 23, 2022
@marchuffnagle marchuffnagle deleted the fix-search-for-bad-collection branch February 23, 2022 16:45
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.

Searching on non-existent collection returns 400 response instead of no results
2 participants