Skip to main content
Seasoned ⭐️
Oct 17, 2022 1:16 PM UTC
Solved

Problem using js-sdk FeatureAPI searchStream method to list all features

In the TNT application at Statnett we are seeking to collect line and point geospatial features through the FeatureAPI. 

We have a dataset that has been populated with data about powerlines and substations, and we want to query the client for all of the features in each of these seperately. As there is no list() method in the FeatureAPI, and the search method is limited to 1000 results, we try to do this using the searchStream() method. Our query looks like this:

client.geospatial.feature.searchStream('ACLineSegment', {
limit: 10000,
output: { jsonStreamFormat: 'NEW_LINE_DELIMITED' as const }
});

 

This seems to work fine for the ‘ACLineSegment’ features but when i replace it with ‘Substation’ the call returns an empty string. I’ve tested with the regular search() and this returns features so I would expect the searchStream method to find these as well. Even stranger is that i quickly tested this functionality before the weekend and it seemed to work fine for ‘Substation’ then. This is however before the line data was uploaded.

From where I sit the most likely explanation seems to be some hickup in JavaScript SDK. Any help solving this or alternate method for listing all features of a certain FeatureType would be much appreciated.

Practitioner ⭐️⭐️⭐️
Oct 24, 2022 11:48 AM UTC

Hi Henrik, the fix is ready. Please test it again.

8 replies

Practitioner ⭐️⭐️⭐️
Oct 17, 2022 2:15 PM UTC

Hi Henrik,

It would be nice if you can provide the request Id from your response. We will look into the log to see what actually happens.

In the mean time, we also provide the list endpoint with paginated results. You can find more detail at https://docs.cognite.com/api/v1/#tag/Geospatial/operation/listFeatures. However, you need to write the query with plain JS because JS SDK does not support it yet.

 

Seasoned ⭐️
Oct 18, 2022 10:57 AM UTC

Thanks Tuan,

x-request-id: 449ea2a4-e225-937d-83c2-bf91cca09d5d

I will check out the altenative you gave as well.

Practitioner ⭐️⭐️⭐️
Oct 18, 2022 1:04 PM UTC

Hi Henrik, 

I found some internal error when streaming request related to closed connection. To eliminate the error from client side, can you check if it works with Python SDK? https://cognite-sdk-python.readthedocs-hosted.com/en/latest/cognite.html#stream-features

Please check here for the client instantiation https://cognite-sdk-python.readthedocs-hosted.com/en/latest/cognite.html#

Seasoned ⭐️
Oct 19, 2022 10:10 AM UTC

It is the same with the Python SDK. ‘ACLineSegment’ feature works fine here as well but ‘Substation’ seems to return an empty generator:

 

 

Practitioner ⭐️⭐️⭐️
Oct 20, 2022 11:56 AM UTC

We made some fixes on our end. Could you try again? @Henrik Svoren 

Edit: The deployment is not ready. I’ll ping again when it is.

Practitioner ⭐️⭐️⭐️
Oct 24, 2022 11:48 AM UTC

Hi Henrik, the fix is ready. Please test it again.

Seasoned ⭐️
Oct 24, 2022 12:26 PM UTC

Looks like it is working as expected now! Thank you for your help 😊

Saagar  Takhi
Practitioner ⭐️⭐️⭐️
Practitioner ⭐️⭐️⭐️
Nov 3, 2022 10:21 AM UTC

Hello @Henrik Svoren ,
Though this issue seems resolved now.

I’m hoping you would be able to use the newly added geospatial list() endpoint to JS SDK version 7.11.0.

Please do let us know if you run into any issues using that.

Thanks & Regards,
Saagar Takhi.