mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
24 lines
753 B
Python
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)
|