src.database.milvus_client.MilvusClient
Bases: DatabaseAdapter
Source code in src/database/milvus_client.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
__init__(config_file, collection_name, vector_dim, additional_fields=None, index_params=None)
Initializes a Milvus client for vector database operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_file
|
str
|
Path to the YAML configuration file. |
required |
collection_name
|
str
|
Name of the Milvus collection to be used or created. |
required |
vector_dim
|
int
|
Dimension of the vectors stored in the collection. |
required |
additional_fields
|
list
|
Additional fields for the collection schema. |
None
|
Source code in src/database/milvus_client.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
add(vector, metadata, check_dup=False)
Adds a vector and its associated metadata to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector
|
list[float]
|
The vector to be added. |
required |
metadata
|
dict
|
Metadata associated with the vector. |
required |
check_dup
|
bool
|
Flag to check for duplicates before insertion (currently not implemented). |
False
|
Source code in src/database/milvus_client.py
47 48 49 50 51 52 53 54 55 56 57 |
|
reset()
Drops the current collection and creates a new one.
Source code in src/database/milvus_client.py
98 99 100 |
|
reset_collection()
Drops the current collection and creates a new one.
Source code in src/database/milvus_client.py
102 103 104 105 106 |
|
search(vector, top_k, distance_range=None, search_params=None, output_fields=None, filter_expr=None)
Performs a vector search in the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector
|
list[float]
|
The query vector. |
required |
top_k
|
int
|
Number of top results to return. |
required |
distance_range
|
list[int, int]
|
Minimum and maximum distances for filtering results. |
None
|
search_params
|
dict
|
Parameters for the search. |
None
|
output_fields
|
list
|
Fields to include in the returned results. |
None
|
filter_expr
|
str
|
Filter expression for conditional search. |
None
|
Returns:
Name | Type | Description |
---|---|---|
SearchResult |
Search results from Milvus. |
Source code in src/database/milvus_client.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|