Search for assets
- async AsyncCogniteClient.assets.search(
- name: str | None = None,
- description: str | None = None,
- query: str | None = None,
- filter: AssetFilter | dict[str, Any] | None = None,
- limit: int = 25,
-
Primarily meant for human-centric use-cases and data exploration, not for programs, since matching and ordering may change over time. Use the list function if stable or exact matches are required.
- Parameters:
name (str | None) – Fuzzy match on name.
description (str | None) – Fuzzy match on description.
query (str | None) – Whitespace-separated terms to search for in assets. Does a best-effort fuzzy search in relevant fields (currently name and description) for variations of any of the search terms, and orders results by relevance.
filter (AssetFilter | dict[str, Any] | None) – Filter to apply. Performs exact match on these fields.
limit (int) – Maximum number of results to return.
- Returns:
List of requested assets
- Return type:
Examples
Search for assets by fuzzy search on name:
>>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> res = client.assets.search(name="some name")
Search for assets by exact search on name:
>>> res = client.assets.search(filter={"name": "some name"})
Search for assets by improved multi-field fuzzy search:
>>> res = client.assets.search(query="TAG 30 XV")
Search for assets using multiple filters, finding all assets with name similar to xyz with parent asset 123 or 456 with source some source:
>>> res = client.assets.search( ... name="xyz", filter={"parent_ids": [123, 456], "source": "some source"} ... )
Search for an asset with an attached label:
>>> my_label_filter = LabelFilter(contains_all=["PUMP"]) >>> res = client.assets.search(name="xyz", filter=AssetFilter(labels=my_label_filter))