Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! Great library, very useful for us.
The Element84 STAC API
/search
endpoint in particular is returning malformed pagination URLs when used viaPOST
. Here's an example of a URL present in thelinks
object within the returned JSON:https://earth-search.aws.element84.com/v0/search?datetime=2020-09-01%2F2020-10-14&intersects=%5Bobject%20Object%5D&collections[]=sentinel-s2-l2a-cogs&page=2&limit=500
This URL was returned after invoking
search.Search.search(url=URL, collections=['sentinel-s2-l2a-cogs'], datetime="2020-09-01/2020-10-14", bbox=[-127.084,31.128,-106.699,49.8379]).items()
fromsatsearch
.These malformed URLS fail to return the correct result-set, because the current logic simply retrieves results for the first page of the result-set N times, where
N = ceil({total result set} / {max page limit})
. For example, I had a result-set of 7159 images (fromfound()
), but inspecting the results ofitems()
revealed that 500 IDs were repeated 15 times . (15 = ceil(7159/500)).To remedy this, I propose ignoring the malformed pagination URLs returned from the API and instead including the
page
paraemeter in the body of the request, which we increment at each iteration. This "auto-paginates" and ensures that the context of the query is sustained throughout the pagination process. Some experimentation with the API reveals that querying forpage
s outside the domain of the data (e.g. page 3 of a 1000-result query with a 500-item page limit) will still return a 200 response code, so to stop the pagination I simply ensure thatfeatures
within the/search
response is empty.I can't find very much documentation for
stac-server
, so I don't really have much information about the workings of the API. However, this fix works for our use-case (executing large result-sets against the STAC api).