Solved

Wildcard listing resources

  • 28 September 2022
  • 3 replies
  • 62 views

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

icon

Best answer by Gaetan Helness 28 September 2022, 16:43

View original

3 replies

Userlevel 3
Badge

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. 

 

Userlevel 3

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

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!

Reply