milvus
              
                 
                
            
          copied
				 1 changed files with 99 additions and 1 deletions
			
			
		| @ -1,2 +1,100 @@ | |||||
| # milvus |  | ||||
|  | # Operator: ANN Insert: Milvus | ||||
| 
 | 
 | ||||
|  | *author: shiyu* | ||||
|  | 
 | ||||
|  | <br /> | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | ## Desription | ||||
|  | 
 | ||||
|  | Insert data into Milvus collections. **Please make sure you have [created Milvus Collection](https://milvus.io/docs/v2.0.x/create_collection.md)  | ||||
|  | and connected Milvus before loading the data.** | ||||
|  | 
 | ||||
|  | <br /> | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | ## Code Example | ||||
|  | 
 | ||||
|  | ### Get the Collection first | ||||
|  | 
 | ||||
|  | ```python | ||||
|  | from pymilvus import Collection, connections | ||||
|  | 
 | ||||
|  | connections.connect(host='localhost', port='19530') | ||||
|  | collection = Collection('your_collection_name') | ||||
|  | ``` | ||||
|  | 
 | ||||
|  | ### Example | ||||
|  | 
 | ||||
|  | *Write the pipeline in simplified style:* | ||||
|  | 
 | ||||
|  | ```python | ||||
|  | import towhee | ||||
|  | 
 | ||||
|  | towhee.dc(your_embeddings) \ | ||||
|  |     .ann_insert.milvus(collection=collection) | ||||
|  | ``` | ||||
|  | 
 | ||||
|  | *Write a same pipeline with explicit inputs/outputs name specifications:* | ||||
|  | 
 | ||||
|  | ```python | ||||
|  | import towhee | ||||
|  | 
 | ||||
|  | towhee.dc['vec'](your_embeddings) \ | ||||
|  |     .ann_insert.milvus['vec', 'results'](collection=collection) \ | ||||
|  |     .show() | ||||
|  | ``` | ||||
|  | 
 | ||||
|  | <img src="./result.png" height="150px"/> | ||||
|  | 
 | ||||
|  | ### Load Collection | ||||
|  | 
 | ||||
|  | > Please load the Collection after inserted data. | ||||
|  | 
 | ||||
|  | ```python | ||||
|  | collection.load() | ||||
|  | ``` | ||||
|  | 
 | ||||
|  | <br /> | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | ## Factory Constructor | ||||
|  | 
 | ||||
|  | Create the operator via the following factory method: | ||||
|  | 
 | ||||
|  | ***ann_insert.milvus(collection)*** | ||||
|  | 
 | ||||
|  | <br /> | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | **Parameters:** | ||||
|  | 
 | ||||
|  | ***collection:*** *str* or *pymilvus.Collection* | ||||
|  | 
 | ||||
|  | The collection name or pymilvus.Collection in Milvus. | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | <br /> | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | ## Interface | ||||
|  | 
 | ||||
|  | **Parameters:** | ||||
|  | 
 | ||||
|  | ***data:*** *list* | ||||
|  | 
 | ||||
|  | The embedding data to be inserted. | ||||
|  | 
 | ||||
|  | <br /> | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | **Returns:** *mr* | ||||
|  | 
 | ||||
|  | Return milvus results with `milvus.insert`. | ||||
|  | |||||
					Loading…
					
					
				
		Reference in new issue
	
	