github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/docs/insert.md (about)

     1  # Insert 
     2  
     3  API to insert data into a specified 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 insert data into.                        | String                   |
    11  | `partitionName` | Name of the collection to insert data into. </br>If empty, default partition will be used. | String |
    12  | `columns`    | Columnar data to insert.                                      | Variadic slice of entity.Column |
    13  
    14  
    15  
    16  ## Response
    17  
    18  - `ids`: entity.Column that represents the IDs of the inserted data
    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      - `ErrCollectionNotExists`, error that the collection with the specified name does not exist.
    25  
    26      - error that the specified field is not valid.
    27      
    28      - error that API invocation failed.
    29  
    30  ## Example
    31  
    32  ```go
    33  ctx := context.Background()
    34  // cli is a valid Client instance
    35  // row-base covert to column-base
    36  ids := make([]int64, 0, len(films))
    37  years := make([]int32, 0, len(films))
    38  vectors := make([][]float32, 0, len(films))
    39  // string field is not supported yet
    40  idTitle := make(map[int64]string)
    41  for idx, film := range films {
    42  	ids = append(ids, film.ID)
    43  	idTitle[film.ID] = film.Title
    44  	years = append(years, film.Year)
    45  	vectors = append(vectors, films[idx].Vector[:]) // prevent same vector
    46  }
    47  idColumn := entity.NewColumnInt64("ID", ids)
    48  yearColumn := entity.NewColumnInt32("Year", years)
    49  vectorColumn := entity.NewColumnFloatVector("Vector", 8, vectors)
    50  
    51  // insert into default partition
    52  _, err = c.Insert(ctx, collectionName, "", idColumn, yearColumn, vectorColumn)
    53  handles the error not nil
    54  ```