Created
August 19, 2022 03:15
-
-
Save masudur-rahman-niloy/b1570cca2930cb1029c5c7ffcab966b4 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 | |
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) | |
) | |
client.indices.refresh(index="test-index") | |
resp = client.search(index="test-index", query={"match_all": {}}) | |
print("Got %d Hits:" % resp['hits']['total']['value']) | |
for hit in resp['hits']['hits']: | |
print("%(timestamp)s %(author)s: %(text)s" % hit["_source"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment