Aggregate Document Count

async AsyncCogniteClient.documents.aggregate_cardinality_properties(
path: SourceFileProperty | list[str] = SourceFileProperty.metadata,
query: str | None = None,
filter: Filter | dict[str, Any] | None = None,
aggregate_filter: AggregationFilter | dict[str, Any] | None = None,
) int

Find approximate paths count for documents.

Parameters:
  • path (SourceFileProperty | list[str]) – The scope in every document to aggregate properties. The only value allowed now is [“sourceFile”, “metadata”]. It means to aggregate only metadata properties (aka keys).

  • 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.

Returns:

The number of documents matching the specified filters and search.

Return type:

int

Examples

Count the number metadata keys for documents in your CDF project:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> count = client.documents.aggregate_cardinality_properties()