Zack Saadioui
8/26/2024
1
2
bash
pip install llama-index vector-stores-elasticsearch
1
2
3
python
from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.vector_stores.elasticsearch import ElasticsearchStore
1
2
3
4
5
python
es_store = ElasticsearchStore(
index_name="your_index_name",
es_url="http://localhost:9200"
)
1
2
3
python
documents = SimpleDirectoryReader('./data_directory/').load_data()
index = VectorStoreIndex.from_documents(documents, storage_context=es_store)
1
2
3
4
python
query_engine = index.as_query_engine()
response = query_engine.query("What are the highlights of the document?")
print(response)
Copyright © Arsturn 2024