# Count points POST http://localhost:6333/collections/{collection_name}/points/count Content-Type: application/json Counts the number of points that match a specified filtering condition. Reference: https://api.qdrant.tech/api-reference/points/count-points ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Count points version: endpoint_points.count_points paths: /collections/{collection_name}/points/count: post: operationId: count-points summary: Count points description: Counts the number of points that match a specified filtering condition. tags: - - subpackage_points parameters: - name: collection_name in: path description: Name of the collection to count in required: true schema: type: string - name: timeout in: query description: If set, overrides global timeout for this request. Unit is seconds. required: false schema: type: integer - name: api-key in: header required: true schema: type: string responses: '200': description: successful operation content: application/json: schema: $ref: '#/components/schemas/Points_count_points_Response_200' requestBody: description: Request counts of points which matches given filtering condition content: application/json: schema: $ref: '#/components/schemas/CountRequest' components: schemas: ShardKey: oneOf: - type: string - type: integer format: uint64 ShardKeySelector1: type: array items: $ref: '#/components/schemas/ShardKey' ShardKeySelector: oneOf: - $ref: '#/components/schemas/ShardKey' - $ref: '#/components/schemas/ShardKeySelector1' CountRequestShardKey: oneOf: - $ref: '#/components/schemas/ShardKeySelector' - description: Any type ValueVariants: oneOf: - type: string - type: integer format: int64 - type: boolean MatchValue: type: object properties: value: $ref: '#/components/schemas/ValueVariants' required: - value MatchText: type: object properties: text: type: string required: - text AnyVariants: oneOf: - type: array items: type: string - type: array items: type: integer format: int64 MatchAny: type: object properties: any: $ref: '#/components/schemas/AnyVariants' required: - any MatchExcept: type: object properties: except: $ref: '#/components/schemas/AnyVariants' required: - except Match: oneOf: - $ref: '#/components/schemas/MatchValue' - $ref: '#/components/schemas/MatchText' - $ref: '#/components/schemas/MatchAny' - $ref: '#/components/schemas/MatchExcept' FieldConditionMatch: oneOf: - $ref: '#/components/schemas/Match' - description: Any type Range: type: object properties: lt: type: - number - 'null' format: double gt: type: - number - 'null' format: double gte: type: - number - 'null' format: double lte: type: - number - 'null' format: double DatetimeRange: type: object properties: lt: type: - string - 'null' format: date-time gt: type: - string - 'null' format: date-time gte: type: - string - 'null' format: date-time lte: type: - string - 'null' format: date-time RangeInterface: oneOf: - $ref: '#/components/schemas/Range' - $ref: '#/components/schemas/DatetimeRange' FieldConditionRange: oneOf: - $ref: '#/components/schemas/RangeInterface' - description: Any type GeoPoint: type: object properties: lon: type: number format: double lat: type: number format: double required: - lon - lat GeoBoundingBox: type: object properties: top_left: $ref: '#/components/schemas/GeoPoint' bottom_right: $ref: '#/components/schemas/GeoPoint' required: - top_left - bottom_right FieldConditionGeoBoundingBox: oneOf: - $ref: '#/components/schemas/GeoBoundingBox' - description: Any type GeoRadius: type: object properties: center: $ref: '#/components/schemas/GeoPoint' radius: type: number format: double required: - center - radius FieldConditionGeoRadius: oneOf: - $ref: '#/components/schemas/GeoRadius' - description: Any type GeoLineString: type: object properties: points: type: array items: $ref: '#/components/schemas/GeoPoint' required: - points GeoPolygon: type: object properties: exterior: $ref: '#/components/schemas/GeoLineString' interiors: type: - array - 'null' items: $ref: '#/components/schemas/GeoLineString' required: - exterior FieldConditionGeoPolygon: oneOf: - $ref: '#/components/schemas/GeoPolygon' - description: Any type ValuesCount: type: object properties: lt: type: - integer - 'null' gt: type: - integer - 'null' gte: type: - integer - 'null' lte: type: - integer - 'null' FieldConditionValuesCount: oneOf: - $ref: '#/components/schemas/ValuesCount' - description: Any type FieldCondition: type: object properties: key: type: string match: $ref: '#/components/schemas/FieldConditionMatch' range: $ref: '#/components/schemas/FieldConditionRange' geo_bounding_box: $ref: '#/components/schemas/FieldConditionGeoBoundingBox' geo_radius: $ref: '#/components/schemas/FieldConditionGeoRadius' geo_polygon: $ref: '#/components/schemas/FieldConditionGeoPolygon' values_count: $ref: '#/components/schemas/FieldConditionValuesCount' is_empty: type: - boolean - 'null' is_null: type: - boolean - 'null' required: - key PayloadField: type: object properties: key: type: string required: - key IsEmptyCondition: type: object properties: is_empty: $ref: '#/components/schemas/PayloadField' required: - is_empty IsNullCondition: type: object properties: is_null: $ref: '#/components/schemas/PayloadField' required: - is_null ExtendedPointId: oneOf: - type: integer format: uint64 - type: string format: uuid HasIdCondition: type: object properties: has_id: type: array items: $ref: '#/components/schemas/ExtendedPointId' required: - has_id HasVectorCondition: type: object properties: has_vector: type: string required: - has_vector Nested: type: object properties: key: type: string filter: $ref: '#/components/schemas/Filter' required: - key - filter NestedCondition: type: object properties: nested: $ref: '#/components/schemas/Nested' required: - nested Condition: oneOf: - $ref: '#/components/schemas/FieldCondition' - $ref: '#/components/schemas/IsEmptyCondition' - $ref: '#/components/schemas/IsNullCondition' - $ref: '#/components/schemas/HasIdCondition' - $ref: '#/components/schemas/HasVectorCondition' - $ref: '#/components/schemas/NestedCondition' - $ref: '#/components/schemas/Filter' FilterShould1: type: array items: $ref: '#/components/schemas/Condition' FilterShould: oneOf: - $ref: '#/components/schemas/Condition' - $ref: '#/components/schemas/FilterShould1' - description: Any type MinShould: type: object properties: conditions: type: array items: $ref: '#/components/schemas/Condition' min_count: type: integer required: - conditions - min_count FilterMinShould: oneOf: - $ref: '#/components/schemas/MinShould' - description: Any type FilterMust1: type: array items: $ref: '#/components/schemas/Condition' FilterMust: oneOf: - $ref: '#/components/schemas/Condition' - $ref: '#/components/schemas/FilterMust1' - description: Any type FilterMustNot1: type: array items: $ref: '#/components/schemas/Condition' FilterMustNot: oneOf: - $ref: '#/components/schemas/Condition' - $ref: '#/components/schemas/FilterMustNot1' - description: Any type Filter: type: object properties: should: $ref: '#/components/schemas/FilterShould' min_should: $ref: '#/components/schemas/FilterMinShould' must: $ref: '#/components/schemas/FilterMust' must_not: $ref: '#/components/schemas/FilterMustNot' CountRequestFilter: oneOf: - $ref: '#/components/schemas/Filter' - description: Any type CountRequest: type: object properties: shard_key: $ref: '#/components/schemas/CountRequestShardKey' filter: $ref: '#/components/schemas/CountRequestFilter' exact: type: boolean HardwareUsage: type: object properties: cpu: type: integer payload_io_read: type: integer payload_io_write: type: integer payload_index_io_read: type: integer payload_index_io_write: type: integer vector_io_read: type: integer vector_io_write: type: integer required: - cpu - payload_io_read - payload_io_write - payload_index_io_read - payload_index_io_write - vector_io_read - vector_io_write CollectionsCollectionNamePointsCountPostResponsesContentApplicationJsonSchemaUsage: oneOf: - $ref: '#/components/schemas/HardwareUsage' - description: Any type CountResult: type: object properties: count: type: integer required: - count Points_count_points_Response_200: type: object properties: usage: $ref: >- #/components/schemas/CollectionsCollectionNamePointsCountPostResponsesContentApplicationJsonSchemaUsage time: type: number format: double status: type: string result: $ref: '#/components/schemas/CountResult' ``` ## SDK Code Examples ```rust use qdrant_client::qdrant::{Condition, CountPointsBuilder, Filter}; use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; client .count( CountPointsBuilder::new("{collection_name}") .filter(Filter::must([Condition::matches( "color", "red".to_string(), )])) .exact(true), ) .await?; ``` ```python from qdrant_client import QdrantClient client = QdrantClient(url="http://localhost:6333") client.count( collection_name="{collection_name}", count_filter=models.Filter( must=[ models.FieldCondition(key="color", match=models.MatchValue(value="red")), ] ), exact=True, ) ``` ```typescript import { QdrantClient } from "@qdrant/js-client-rest"; const client = new QdrantClient({ host: "localhost", port: 6333 }); client.count("{collection_name}", { filter: { must: [ { key: "color", match: { value: "red", }, }, ], }, exact: true, }); ``` ```go package client import ( "context" "fmt" "github.com/qdrant/go-client/qdrant" ) func count() { client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) if err != nil { panic(err) } count, err := client.Count(context.Background(), &qdrant.CountPoints{ CollectionName: "{collection_name}", Filter: &qdrant.Filter{ Must: []*qdrant.Condition{ qdrant.NewMatch("color", "red"), }, }, }) if err != nil { panic(err) } fmt.Println("Count:", count) } ``` ```java import static io.qdrant.client.ConditionFactory.matchKeyword; import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantGrpcClient; import io.qdrant.client.grpc.Points.Filter; QdrantClient client = new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); client .countAsync( "{collection_name}", Filter.newBuilder().addMust(matchKeyword("color", "red")).build(), true) .get(); ``` ```csharp using Qdrant.Client; using static Qdrant.Client.Grpc.Conditions; var client = new QdrantClient("localhost", 6334); await client.CountAsync( collectionName: "{collection_name}", filter: MatchKeyword("color", "red"), exact: true ); ``` ```ruby require 'uri' require 'net/http' url = URI("http://localhost:6333/collections/collection_name/points/count") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(url) request["api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` ```php request('POST', 'http://localhost:6333/collections/collection_name/points/count', [ 'body' => '{}', 'headers' => [ 'Content-Type' => 'application/json', 'api-key' => '', ], ]); echo $response->getBody(); ``` ```swift import Foundation let headers = [ "api-key": "", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:6333/collections/collection_name/points/count")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```