IHTSDO / snowstorm

Scalable SNOMED CT Terminology Server using Elasticsearch
Other
203 stars 80 forks source link

Request for Clarification on Unlimited Pagination for {branch}/concepts Endpoint #602

Closed paloma-cito closed 3 months ago

paloma-cito commented 3 months ago

Hello,

I am developing an application using Snowstorm and have encountered an issue with the GET /{branch}/concepts endpoint. Specifically, I am running into the 10,000 results limit, which is problematic as I often need to process ECL queries that return more than 10,000 results.

In the documentation, I noticed that there is an option to disable this limitation for another endpoint (GET /browser/{branch}/concepts) using the following configuration:

snowstorm.rest-api.allowUnlimitedConceptPagination

Is a similar option available for the GET /{branch}/concepts endpoint? If so, could you provide guidance on how to enable it?

Any assistance you can provide would be greatly appreciated.

kaicode commented 3 months ago

The Snowstorm native API that you are using does not allow pagination beyond 10,000 results when using the offset parameter. However it does allow unlimited pagination via the searchAfter parameter. We have this parameter as a workaround for a restriction in Elasticsearch. Elasticsearch that is not able to paginate using offset without reading all the results from previous pages into memory and that gives poor performance.

To paginate using searchAfter:

For example the first three pages from the Jan 2024 International Release could be loaded like this:

The allowUnlimitedConceptPagination parameter you mentioned only blocks the /browser/{branch}/concepts endpoint. This is disabled by default to prevent anyone extracting the complete set of concept definitions from the public browser.

paloma-cito commented 3 months ago

Hi,

Thank you very much for your prompt and thorough response. Your solution solved my issue, and I truly appreciate your help!

Best regards,

Paloma