Created
August 19, 2022 03:12
-
-
Save masudur-rahman-niloy/8270f01beb1d85ef568dbce9871dcb32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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