Documentation
¶
Index ¶
- Variables
- func CreateCollection(schema *entity.Schema, milvusClient client.Client) (funcError error)
- func CreateCustomSchema(collectionName string, fields []SchemaField, description string) (*entity.Schema, error)
- func CreateIndexes(collectionName string, milvusClient client.Client, guidFieldName string, ...) (funcError error)
- func Initialize() (milvusClient client.Client, funcError error)
- func InsertData(collectionName string, dataToSend []interface{}) (funcError error)
- type AutoIdFlex
- type MilvusInsertData
- type MilvusInsertResponse
- type MilvusQueryResponse
- type MilvusRequest
- type MilvusSearchResponse
- type SchemaField
Constants ¶
This section is empty.
Variables ¶
var ( CallsBatchSize = 10000 DumpBatchSize = 10000 MilvusConnectionTimeout = 5 * time.Second MilvusConnectionRetries = 40 MaxSearchRetrievalCount = 16384 )
Global variables
Functions ¶
func CreateCollection ¶
CreateCollection creates a collection in the Milvus DB.
Parameters:
- schema: Schema of the collection to be created.
- milvusClient: Milvus client.
Returns:
- error: Error if any issue occurs during creating the collection.
func CreateCustomSchema ¶
func CreateCustomSchema(collectionName string, fields []SchemaField, description string) (*entity.Schema, error)
CreateCustomSchema function to generate a Milvus schema based on user input
func CreateIndexes ¶
func CreateIndexes(collectionName string, milvusClient client.Client, guidFieldName string, denseVectorFieldName string, sparseVectorFieldName string) (funcError error)
CreateIndexes creates indexes for the Milvus DB. Firstly, a scalar index is created for the guid field. Secondly, a vector index is created for the embeddings field.
Parameters:
- collectionName: Name of the collection to create the indexes for.
- milvusClient: Milvus client.
Returns:
- error: Error if any issue occurs during creating the indexes.
func Initialize ¶
Initialize initializes the Milvus DB. The function first creates a Milvus client, then creates a collection with the specified name, creates indexes on the collection, and loads the collection.
Parameters:
- collectionName: Name of the collection to be initialized.
Returns:
- error: Error if any issue occurs during initializing the Milvus DB.
func InsertData ¶
InsertData sends data to the Milvus DB in order to populate the vector database. The function sends the data in batches of const "CallsBatchSize" entries. The data is sent via HTTP POST requests.
Parameters:
- collectionName: Name of the collection to send the data to.
- dataToSend: Data to be sent to the Milvus DB.
Returns:
- error: Error if any issue occurs during sending the data to the Milvus DB.
Types ¶
type AutoIdFlex ¶
type AutoIdFlex int64
type MilvusInsertData ¶
type MilvusInsertData struct {
InsertCount int `json:"insertCount"`
}
type MilvusInsertResponse ¶
type MilvusInsertResponse struct { Code int `json:"code"` Message string `json:"message"` InsertData MilvusInsertData `json:"data"` }
type MilvusQueryResponse ¶
type MilvusRequest ¶
type MilvusRequest struct { // Common fields CollectionName string `json:"collectionName"` // Insert request Data []interface{} `json:"data,omitempty"` // Search and Query request OutputFields []string `json:"outputFields,omitempty"` Filter *string `json:"filter,omitempty"` Limit *int `json:"limit,omitempty"` Offset *int `json:"offset,omitempty"` // Search request DenseVector []float32 `json:"dense_vector,omitempty"` SparseVector map[uint]float32 `json:"sparse_vector,omitempty"` // Delete entry request AutoIds []AutoIdFlex `json:"id,omitempty"` }