You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/templates/elastic-query-generator/ingest.py

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)