Closed momocat-aric closed 3 months ago
It appears there's a mix-up with the parameter used to specify the database or collection name in your code. In the version of LlamaIndex you're using, the MilvusVectorStore
class expects a collection_name
parameter for defining where the data should be stored, not db_name
. Here's how you can adjust your code to ensure data is inserted into the correct collection:
from llama_index.legacy.vector_stores.milvus import MilvusVectorStore
vector_store = MilvusVectorStore(
dim=384,
collection_name="New_DBName", # Use collection_name instead of db_name
overwrite=True
# Include other necessary parameters like URI and token if needed
)
By specifying collection_name="New_DBName"
, your data will be inserted into the "New_DBName" collection. Ensure that any other required parameters, such as the Milvus instance URI and token (if using RBAC), are also correctly set in your MilvusVectorStore
initialization.
This adjustment should direct your insert operations to the intended collection. If you encounter further issues or have additional questions, feel free to ask.
It appears there's a mix-up with the parameter used to specify the database or collection name in your code. In the version of LlamaIndex you're using, the
MilvusVectorStore
class expects acollection_name
parameter for defining where the data should be stored, notdb_name
. Here's how you can adjust your code to ensure data is inserted into the correct collection:from llama_index.legacy.vector_stores.milvus import MilvusVectorStore vector_store = MilvusVectorStore( dim=384, collection_name="New_DBName", # Use collection_name instead of db_name overwrite=True # Include other necessary parameters like URI and token if needed )
By specifying
collection_name="New_DBName"
, your data will be inserted into the "New_DBName" collection. Ensure that any other required parameters, such as the Milvus instance URI and token (if using RBAC), are also correctly set in yourMilvusVectorStore
initialization.This adjustment should direct your insert operations to the intended collection. If you encounter further issues or have additional questions, feel free to ask.
Sources
About Dosu
not solve my problem. Milvus support user to manage different database (note: not the collection), you can pass in the db_name to connect different database using pymilvus. So I want to know, how can I access different database using llamaindex, so that I can insert different data into different database.
To insert data into different databases using LlamaIndex with Milvus, it's important to clarify that Milvus itself does not use the concept of a database
as a container for collections, unlike traditional relational databases. Instead, Milvus organizes data into collections
, which are analogous to tables in SQL databases.
When working with LlamaIndex to interact with Milvus, you specify the target for data insertion through the collection_name
parameter, not db_name
, because each collection in Milvus is directly accessible without the need for specifying a database. Here's how you can specify the collection:
from llama_index.legacy.vector_stores.milvus import MilvusVectorStore
milvus_store = MilvusVectorStore(
uri="http://yourmilvusinstance:19530", # Your Milvus instance URI
collection_name="Your_Collection_Name", # The collection you want to insert data into
dim=128, # Dimension of your embeddings
# Include any other necessary parameters
)
Replace "http://yourmilvusinstance:19530"
with your Milvus instance's URI, "Your_Collection_Name"
with the name of the collection you wish to use, and adjust the dim
parameter to match your data's dimensions.
The db_name
parameter you mentioned is not used in this context. If you're referring to a setup where you're using MongoDB as a metadata store alongside Milvus, db_name
would specify the MongoDB database for metadata, not a Milvus collection.
For more detailed operations and configurations, refer to the Milvus documentation on collections and the LlamaIndex GitHub repository for specifics on using the MilvusVectorStore
class.
@momocat-aric db_name
is not a valid kwarg to milvus vector store. It seems like it might get passed in as part of kwargs, but I wouldn't be surprised if this wasn't supported properly
Feel free to checkout the source code https://github.com/run-llama/llama_index/blob/ce5963486d8b99fa045659dbdb7bd1398d6b7da5/llama-index-integrations/vector_stores/llama-index-vector-stores-milvus/llama_index/vector_stores/milvus/base.py#L173
@momocat-aric
db_name
is not a valid kwarg to milvus vector store. It seems like it might get passed in as part of kwargs, but I wouldn't be surprised if this wasn't supported properlyFeel free to checkout the source code
Thanks for your reply.
Yes, I debugged the code and found the db_name actually can be passed into MilvusClient class. But it still not work, that is weird.
And I tried another way: use "/" to concat the URI and db_name, it works, like:
URI = "<URI>/<DB_NAME>"
vector_store = MilvusVectorStore(dim=N, uri=URI, overwrite=True)
Question Validation
Question
I use llamaindex to connect the Milvus, and I specify the Milvus db-name as "New_DBName". But when insert data, I found all the data is inserted into 'default' database. Following is my connect code:
vector_store = MilvusVectorStore(dim=384, db_name="New_DBName", overwrite=True)
Env: python 3.9 llamaindex 0.9.48