Skip to main content
Answer

Wildcard listing resources

  • September 28, 2022
  • 3 replies
  • 76 views

Anders Brakestad
Seasoned

I am listing time series for a given asset, and get a lot of results. I need to filter based on the time series external ID, but the only option is by using the “external_id_prefix” argument to the list function. So I build up the prefix left to right. Somewhere in the external id is a parameter that I do not care about, and after comes a new parameter that I want a particular value of. Concrete example of external IDs:

IAA_Miros_Weather_Data_WIA_008
IAA_Miros_Weather_Data_WIB_008
IAA_Miros_Weather_Data_WIC_008
IAA_Miros_Weather_Data_WID_008
IAA_Miros_Weather_Data_WIE_008

I am interested in only getting time series with external IDs that contain “_WI” and that end with “008”. Is there a way to list time series with a wildcard? Something like this:

client.time_series.list(
asset_ids=[my_asset_id],
limit=None,
external_id_prefix="IAA_Miros_Weather_Data_WI*_008",
partitions=4
)

I could of course obtain the relevant time series by filtering after the fact. Something like this

result = client.time_series.list(
asset_ids=[my_asset_id],
limit=None,
external_id_prefix="IAA_Miros_Weather_Data_WI",
partitions=4
).to_pandas()
df = result.loc[result.externalId.str.endswith("008")]

Or is there functionality already available?

Sincerely,

Anders Brakestad

Best answer by Gaetan Helness

Hi Anders, 

There is not any fuzzy search on the externalID field, but we do support fuzzy search on the name and description. 

https://docs.cognite.com/api/v1/#tag/Time-series/operation/searchTimeSeries
Depending on the data model, do you have possibility to filter on that information somewhere else like the metadata field for example? 

If not, I guess filtering after the fact is a way to go as well. 

 

3 replies

Gaetan  Helness
MVP
Forum|alt.badge.img+1

Hi Anders, 

There is not any fuzzy search on the externalID field, but we do support fuzzy search on the name and description. 

https://docs.cognite.com/api/v1/#tag/Time-series/operation/searchTimeSeries
Depending on the data model, do you have possibility to filter on that information somewhere else like the metadata field for example? 

If not, I guess filtering after the fact is a way to go as well. 

 


  • Seasoned Practitioner
  • October 10, 2022

Hi @Anders Brakestad, did Gaetan’s reply above help you? 


Anders Brakestad
Seasoned

Hi again,

Yes, I answer clarified some restrictions on searching and filtering. In the specific case in the original post, I cannot filter on this parameter in the metadata, so I need to do it ad hoc.

Thanks for the help!