You can perform vector operations on collections or partitions. This article talks about the following topics:
Randomly generate 20 256-dimensional vectors:
>>> import random # Generate 20 vectors of 256 dimensions. >>> vectors = [[random.random() for _ in range(256)] for _ in range(20)]
Insert a list of vectors. If you do not specify vector IDs, Milvus automatically assigns IDs to the vectors.
# Insert vectors. >>> milvus.insert(collection_name='test01', records=vectors)
You can also specify the vector IDs:
>>> vector_ids = [id for id in range(20)] >>> milvus.insert(collection_name='test01', records=vectors, ids=vector_ids)
>>> milvus.insert('test01', vectors, partition_tag="tag01")
Suppose your collection contains the following vector IDs:
>>> ids = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
You can delete the vectors with the following command:
>>> milvus.delete_entity_by_id(collection_name='test01', id_array=ids)
delete, you can call
flushagain to ensure that the newly inserted data is visible and the deleted data is no longer recoverable.