Aggregate Document Unique Values
- async AsyncCogniteClient.documents.aggregate_unique_values(
- property: DocumentProperty | SourceFileProperty | list[str] | str,
- query: str | None = None,
- filter: Filter | dict[str, Any] | None = None,
- aggregate_filter: AggregationFilter | dict[str, Any] | None = None,
- limit: int = 25,
Get unique properties with counts for documents.
- Parameters:
property (DocumentProperty | SourceFileProperty | list[str] | str) – The property to group by.
query (str | None) – The free text search query, for details see the documentation referenced above.
filter (Filter | dict[str, Any] | None) – The filter to narrow down the documents to count cardinality.
aggregate_filter (AggregationFilter | dict[str, Any] | None) – The filter to apply to the resulting buckets.
limit (int) – Maximum number of items. Defaults to 25.
- Returns:
List of unique values of documents matching the specified filters and search.
- Return type:
UniqueResultList
Examples
Get the unique types with count of documents in your CDF project:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes.documents import DocumentProperty >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> result = client.documents.aggregate_unique_values(DocumentProperty.mime_type) >>> unique_types = result.unique
Get the different languages with count for documents with external id prefix “abc”:
>>> from cognite.client.data_classes import filters >>> from cognite.client.data_classes.documents import DocumentProperty >>> is_abc = filters.Prefix(DocumentProperty.external_id, "abc") >>> result = client.documents.aggregate_unique_values( ... DocumentProperty.language, filter=is_abc ... ) >>> unique_languages = result.unique
Get the unique mime types with count of documents, but exclude mime types that start with text:
>>> from cognite.client.data_classes.documents import DocumentProperty >>> from cognite.client.data_classes import aggregations >>> agg = aggregations >>> is_not_text = agg.Not(agg.Prefix("text")) >>> result = client.documents.aggregate_unique_values( ... DocumentProperty.mime_type, aggregate_filter=is_not_text ... ) >>> unique_mime_types = result.unique