langchain/templates/elastic-query-generator/ingest.py
2023-10-29 15:50:09 -07:00

24 lines
753 B
Python

from elasticsearch import Elasticsearch
# Setup Elasticsearch
# This shows how to set it up for a cloud hosted version
# Password for the 'elastic' user generated by Elasticsearch
ELASTIC_PASSWORD = "..."
# Found in the 'Manage Deployment' page
CLOUD_ID = "..."
# Create the client instance
db = Elasticsearch(cloud_id=CLOUD_ID, basic_auth=("elastic", ELASTIC_PASSWORD))
customers = [
{"firstname": "Jennifer", "lastname": "Walters"},
{"firstname": "Monica", "lastname": "Rambeau"},
{"firstname": "Carol", "lastname": "Danvers"},
{"firstname": "Wanda", "lastname": "Maximoff"},
{"firstname": "Jennifer", "lastname": "Takeda"},
]
for i, customer in enumerate(customers):
db.create(index="customers", document=customer, id=i)