Documentation
¶
Index ¶
- Variables
- func CreateCollection(schema *entity.Schema) (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{}, objectFieldName string, ...) (funcError error)
- func QueryDuplicates(collectionName string, data []interface{}, objectFieldName string, ...) (duplicatedEntriesId [][]int64, funcError error)
- func RemoveDuplicates(collectionName string, dataIds []int64) (deleteCount int, funcError error)
- type ArrayFilter
- type AutoIdFlex
- type JsonFilter
- type MilvusDeleteData
- type MilvusDeleteResponse
- type MilvusInsertData
- type MilvusInsertResponse
- type MilvusQueryResponse
- type MilvusRequest
- type MilvusSearchResponse
- type SchemaField
Constants ¶
This section is empty.
Variables ¶
var ( CallsBatchSize = 500 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.
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 ¶
func InsertData(collectionName string, dataToSend []interface{}, objectFieldName string, idFieldName string) (funcError error)
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.
- objectFieldName: Name of the field in the data go object to be used as the object field.
- idFieldName: Name of the field in the milvus schema to be used as the ID field.
Returns:
- error: Error if any issue occurs during sending the data to the Milvus DB.
func QueryDuplicates ¶ added in v0.7.30
func QueryDuplicates(collectionName string, data []interface{}, objectFieldName string, idFieldName string) (duplicatedEntriesId [][]int64, funcError error)
QueryDuplicates queries the Milvus database for the provided data and retrieves the duplicates.
Parameters:
- collectionName: Name of the collection in the Milvus database.
- data: Data to send to the Milvus database.
- objectFieldName: Name of the field in the data go object to be used as the object field.
- idFieldName: Name of the field in the milvus schema to be used as the ID field.
Returns:
- removedData: Data that was removed from the Milvus database.
- error: Error if any issue occurs during querying the Milvus database.
func RemoveDuplicates ¶ added in v0.7.30
RemoveDuplicates removes duplicates from the Milvus database.
Parameters:
- collectionName: Name of the collection in the Milvus database.
- dataIds: IDs of the data to remove from the Milvus database.
Returns:
- deleteCount: Number of entries removed from the Milvus database.
- error: Error if any issue occurs during querying the Milvus database.
Types ¶
type ArrayFilter ¶ added in v0.7.27
type AutoIdFlex ¶
type AutoIdFlex int64
type JsonFilter ¶ added in v0.7.27
type JsonFilter struct {
FieldName string `json:"fieldName"`
FieldType string `json:"fieldType" description:"Can be either string or array."` // "string" or "array"
FilterData []string `json:"filterData"`
NeedAll bool `json:"needAll" description:"Only needed if the FieldType is array."` // only needed for array fields
}
type MilvusDeleteData ¶ added in v0.7.27
type MilvusDeleteData struct {
DeleteCount int `json:"deleteCount"`
}
type MilvusDeleteResponse ¶ added in v0.7.27
type MilvusDeleteResponse struct {
Code int `json:"code"`
Data MilvusDeleteData `json:"data"`
Message string `json:"message"`
}
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 MilvusQueryResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data []interface{} `json:"data"`
}
func Query ¶ added in v0.7.27
func Query(collectionName string, responseLimit int, outputFields []string, filterExpression string) (response MilvusQueryResponse, funcError error)
Query queries the Milvus database.
This function queries the Milvus database with an HTTP POST request.
Parameters:
- collectionName: Name of the collection to query.
- responseLimit: Maximum number of responses.
- outputFields: Fields to return in the response.
- filterExpression: Filters to apply to the query.
Returns:
- response: Response from the Milvus database.
- error: Error if any issue occurs while querying the Milvus database.
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"`
}