Milvus
Zilliz
< Docs
  • Node

count()

This operation counts the number of entities that match the specified filtering expression.

count(data): Promise<CountResult>

Request Syntax

milvusClient.count({
    db_name?: string,
    collection_name: string,
    expr?: string,
    timeout?: boolean
})

PARAMETERS:

  • db_name (str) -

    The name of the database that holds the target collection.

  • collection_name (str) -

    [REQUIRED]

    The name of the collection to create an alias for.

  • expr (string) -

    A scalar filtering condition to filter matching entities.

    You can set this parameter to an empty string to skip scalar filtering. To build a scalar filtering condition, refer to Boolean Expression Rules.

  • timeout (number)

    The timeout duration for this operation. Setting this to None indicates that this operation timeouts when any response arrives or any error occurs.

RETURNS Promise<CountResult>

This method returns a promise that resolves to a CountResult object.

{
    data: number,
    status: {
        code: number,
        error_code: number | string,
        reason: string
    }
}

PARAMETERS:

  • data (number) -

    The number of entities that match the specified filtering expression.

  • status (object) -

    • code (number) -

      A code that indicates the operation result. It remains 0 if this operation succeeds.

    • error_code (string | number) -

      An error code that indicates an occurred error. It remains Success if this operation succeeds.

    • reason (string) -

      The reason that indicates the reason for the reported error. It remains an empty string if this operation succeeds.

Examples

const milvusClient = new milvusClient(MILUVS_ADDRESS);
const num_entities = await milvusClient.count({
   collection_name: 'my_collection',
   expr: "age in [1,2,3,4,5,6,7,8]",
});

// 1000

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?