# Create payload index PUT http://localhost:6333/collections/{collection_name}/index Content-Type: application/json Creates a payload index for a field in the specified collection. Reference: https://api.qdrant.tech/api-reference/indexes/create-field-index ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create payload index version: endpoint_indexes.create_field_index paths: /collections/{collection_name}/index: put: operationId: create-field-index summary: Create payload index description: Creates a payload index for a field in the specified collection. tags: - - subpackage_indexes parameters: - name: collection_name in: path description: Name of the collection required: true schema: type: string - name: wait in: query description: If true, wait for changes to actually happen required: false schema: type: boolean - name: ordering in: query description: define ordering guarantees for the operation required: false schema: $ref: '#/components/schemas/WriteOrdering' - name: api-key in: header required: true schema: type: string responses: '200': description: successful operation content: application/json: schema: $ref: '#/components/schemas/Indexes_create_field_index_Response_200' requestBody: description: Field name content: application/json: schema: $ref: '#/components/schemas/CreateFieldIndex' components: schemas: WriteOrdering: type: string enum: - value: weak - value: medium - value: strong PayloadSchemaType: type: string enum: - value: keyword - value: integer - value: float - value: geo - value: text - value: bool - value: datetime - value: uuid KeywordIndexType: type: string enum: - value: keyword KeywordIndexParams: type: object properties: type: $ref: '#/components/schemas/KeywordIndexType' is_tenant: type: - boolean - 'null' on_disk: type: - boolean - 'null' required: - type IntegerIndexType: type: string enum: - value: integer IntegerIndexParams: type: object properties: type: $ref: '#/components/schemas/IntegerIndexType' lookup: type: - boolean - 'null' range: type: - boolean - 'null' is_principal: type: - boolean - 'null' on_disk: type: - boolean - 'null' required: - type FloatIndexType: type: string enum: - value: float FloatIndexParams: type: object properties: type: $ref: '#/components/schemas/FloatIndexType' is_principal: type: - boolean - 'null' on_disk: type: - boolean - 'null' required: - type GeoIndexType: type: string enum: - value: geo GeoIndexParams: type: object properties: type: $ref: '#/components/schemas/GeoIndexType' on_disk: type: - boolean - 'null' required: - type TextIndexType: type: string enum: - value: text TokenizerType: type: string enum: - value: prefix - value: whitespace - value: word - value: multilingual TextIndexParams: type: object properties: type: $ref: '#/components/schemas/TextIndexType' tokenizer: $ref: '#/components/schemas/TokenizerType' min_token_len: type: - integer - 'null' max_token_len: type: - integer - 'null' lowercase: type: - boolean - 'null' on_disk: type: - boolean - 'null' required: - type BoolIndexType: type: string enum: - value: bool BoolIndexParams: type: object properties: type: $ref: '#/components/schemas/BoolIndexType' on_disk: type: - boolean - 'null' required: - type DatetimeIndexType: type: string enum: - value: datetime DatetimeIndexParams: type: object properties: type: $ref: '#/components/schemas/DatetimeIndexType' is_principal: type: - boolean - 'null' on_disk: type: - boolean - 'null' required: - type UuidIndexType: type: string enum: - value: uuid UuidIndexParams: type: object properties: type: $ref: '#/components/schemas/UuidIndexType' is_tenant: type: - boolean - 'null' on_disk: type: - boolean - 'null' required: - type PayloadSchemaParams: oneOf: - $ref: '#/components/schemas/KeywordIndexParams' - $ref: '#/components/schemas/IntegerIndexParams' - $ref: '#/components/schemas/FloatIndexParams' - $ref: '#/components/schemas/GeoIndexParams' - $ref: '#/components/schemas/TextIndexParams' - $ref: '#/components/schemas/BoolIndexParams' - $ref: '#/components/schemas/DatetimeIndexParams' - $ref: '#/components/schemas/UuidIndexParams' PayloadFieldSchema: oneOf: - $ref: '#/components/schemas/PayloadSchemaType' - $ref: '#/components/schemas/PayloadSchemaParams' CreateFieldIndexFieldSchema: oneOf: - $ref: '#/components/schemas/PayloadFieldSchema' - description: Any type CreateFieldIndex: type: object properties: field_name: type: string field_schema: $ref: '#/components/schemas/CreateFieldIndexFieldSchema' required: - field_name 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 CollectionsCollectionNameIndexPutResponsesContentApplicationJsonSchemaUsage: oneOf: - $ref: '#/components/schemas/HardwareUsage' - description: Any type UpdateStatus: type: string enum: - value: acknowledged - value: completed UpdateResult: type: object properties: operation_id: type: - integer - 'null' format: uint64 status: $ref: '#/components/schemas/UpdateStatus' required: - status Indexes_create_field_index_Response_200: type: object properties: usage: $ref: >- #/components/schemas/CollectionsCollectionNameIndexPutResponsesContentApplicationJsonSchemaUsage time: type: number format: double status: type: string result: $ref: '#/components/schemas/UpdateResult' ``` ## SDK Code Examples ```rust use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType}; use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; client .create_field_index( CreateFieldIndexCollectionBuilder::new( "{collection_name}", "{field_name}", FieldType::Keyword, ), ) .await?; ``` ```python from qdrant_client import QdrantClient client = QdrantClient(url="http://localhost:6333") client.create_payload_index( collection_name="{collection_name}", field_name="name_of_the_field_to_index", field_schema="keyword", ) ``` ```typescript import { QdrantClient } from "@qdrant/js-client-rest"; const client = new QdrantClient({ host: "localhost", port: 6333 }); client.createPayloadIndex("{collection_name}", { field_name: "{field_name}", field_schema: "keyword", }); ``` ```go package client import ( "context" "github.com/qdrant/go-client/qdrant" ) func createFieldIndex() { client, err := qdrant.NewClient(&qdrant.Config{ Host: "localhost", Port: 6334, }) if err != nil { panic(err) } _, err = client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{ CollectionName: "{collection_name}", FieldName: "name_of_the_field_to_index", FieldType: qdrant.FieldType_FieldTypeKeyword.Enum(), }) if err != nil { panic(err) } } ``` ```java import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantGrpcClient; import io.qdrant.client.grpc.Collections.PayloadSchemaType; QdrantClient client = new QdrantClient( QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); client.createPayloadIndexAsync( "{collection_name}", "{field_name}", PayloadSchemaType.Keyword, null, true, null, null); ``` ```csharp using Qdrant.Client; var client = new QdrantClient("localhost", 6334); await client.CreatePayloadIndexAsync( collectionName: "{collection_name}", fieldName: "name_of_the_field_to_index" ); ``` ```ruby require 'uri' require 'net/http' url = URI("http://localhost:6333/collections/collection_name/index") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Put.new(url) request["api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"field_name\": \"string\"\n}" response = http.request(request) puts response.read_body ``` ```php request('PUT', 'http://localhost:6333/collections/collection_name/index', [ 'body' => '{ "field_name": "string" }', 'headers' => [ 'Content-Type' => 'application/json', 'api-key' => '', ], ]); echo $response->getBody(); ``` ```swift import Foundation let headers = [ "api-key": "", "Content-Type": "application/json" ] let parameters = ["field_name": "string"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:6333/collections/collection_name/index")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" 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() ```