Find answers from the community

Updated 3 months ago

Weaviate

Is there a way to create a VectorStore that can query a collection/index in a vector DB that is already populated with data which was not ingested via LlamaIndex?

For example, something like this:
Plain Text
vector_store = WeaviateVectorStore(weaviate_client = client, index_name="test", text_key="source_text")

# setting up the storage for the embeddings
storage_context = StorageContext.from_defaults(vector_store = vector_store)

# set up the index
index = VectorStoreIndex([], storage_context = storage_context)

but this tries to create the index for me under the hood. What I want is to point at an already existing index called "test" which is already full of vectors and query against it using a query engine or a retriever.

if i do something like this vector_store.index_name = "Test" it will point at my index but it won't return any results. I suspect this is because its tracking the nodes and I initialized the VectorStoreIndex without any nodes.

Any help would be greatly appreciated!
L
g
10 comments
When you construct the vector store object, set the text_field kwarg to be the field in your weaviate db that contains the text

https://github.com/run-llama/llama_index/blob/97b684b7570a5ca48e01ee4e20c5bea68a9e4c71/llama_index/vector_stores/weaviate.py#L86
I tried that, in this code block down below and it returns an empty response:
Plain Text
# initialize it to nothing so that it doesn't attempt to create it
vector_store = WeaviateVectorStore(weaviate_client=client, index_name=None, text_key="source_data", text_field="source_data")

embeddings
storage_context = StorageContext.from_defaults(vector_store = vector_store)

index = VectorStoreIndex([], storage_context = storage_context)

vector_store.index_name = "Test"

query_engine = index.as_query_engine()
response = query_engine.query("What is the general theme of movie reviews?")

print(response)
also tried it without text_key
oh I think you also need to set index name still, otherwise it doesn't connect to anything
tried that and it still returns an an empty response.
do you know if this line here:
index = VectorStoreIndex([], storage_context = storage_context)
where I pass the index an empty list as the value for the nodes, is causing the retrieval to fail somehow?
Here it says that the Base retriever tries to retrieve nodes given a query - https://gpt-index.readthedocs.io/en/stable/api_reference/query/retrievers.html - can I interpret this to mean that if I don't pass in any nodes to the index, it cannot perform the operation?
It ends up calling query on the vector store. Your setup should be fine πŸ€”
I debugged it successfully. It was actually an issue with the way the weaviate class was set up
thanks for your help
Add a reply
Sign up and join the conversation on Discord