Skip to content

Instantly share code, notes, and snippets.

@masudur-rahman-niloy
Created August 19, 2022 03:12
Show Gist options
  • Save masudur-rahman-niloy/8270f01beb1d85ef568dbce9871dcb32 to your computer and use it in GitHub Desktop.
Save masudur-rahman-niloy/8270f01beb1d85ef568dbce9871dcb32 to your computer and use it in GitHub Desktop.
from elasticsearch import Elasticsearch
from datetime import datetime
import sys
ELASTIC_PASSWORD = sys.argv[1]
client = Elasticsearch(
"https://localhost:9200",
ca_certs="/etc/elasticsearch/certs/http_ca.crt",
basic_auth=("elastic", ELASTIC_PASSWORD)
)
print(client.info())
doc = {
'author': 'niloy',
'text': 'Inserting bulk',
'timestamp': datetime.now(),
}
for i in range(100):
resp = client.index(index="test-index", id=i, document=doc)
print(resp['result'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment