-
Notifications
You must be signed in to change notification settings - Fork 28
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
Conversation
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) |
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 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.
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.
Fixed in 4fd74d3
...obj, | ||
[key]: parameters[key] | ||
}), {}) | ||
const searchParameters = pickBy(parameters) |
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.
are parameters that have the value 0
going to be strings here and therefore truthy?
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.
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.
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.
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.
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.