github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/docs/create_index.md (about) 1 # Create Index 2 3 API to create index on vector field of a collection. 4 5 ## Parameters 6 7 | Parameter | Description | Type | 8 | ------------ | ------------------------------------------------------------- | ------------------------ | 9 | `ctx` | Context to control API invocation process. | context.Context | 10 | `collName` | Name of the collection to build index on. | String | 11 | `fieldName` | Name of the field to build index on. | String | 12 | `idx` | Index type and specific parameters. | entity.Index | 13 | `async` | Switch value of the sync/async behavior. </br>Note: the deadline of context is not applied in sync creation precess. | Boolean | 14 15 16 17 18 ## Response 19 20 `err`: error in the process (if any). Possible errors are listed below: 21 22 - `ErrClientNotReady`, error that the client is not connected. 23 24 - error that the specified field is not valid. 25 26 - error that API invocation failed. 27 28 ## Example 29 30 ```go 31 ctx := context.Background() 32 idx, err := entity.NewIndexIvfFlat(entity.L2, 2) 33 // handles err if the newly created index is not valid 34 // cli is a valid Client instance 35 err := cli.CreateIndex(ctx, "TestCollection", "Vector", idx, false) 36 // handles the error not nil 37 ```