Skip to content

Instantly share code, notes, and snippets.

@joeywhelan
Last active March 14, 2025 20:02
Show Gist options
  • Select an option

  • Save joeywhelan/82ff40d840e24c78e5c37c1df62410ae to your computer and use it in GitHub Desktop.

Select an option

Save joeywhelan/82ff40d840e24c78e5c37c1df62410ae to your computer and use it in GitHub Desktop.
from elasticsearch import Elasticsearch
WEST_IP = "172.18.0.4"
client = Elasticsearch(f"https://{WEST_IP}:9200", ca_certs="../../west/west-http-ca.crt", basic_auth=("elastic", "elastic"))
resp = client.search(index=["west_ccs", "east_remote:east_ccs"], query={"range": {"release_date": {"gte": 1985}}})
for hit in resp["hits"]["hits"]:
print(hit["_source"])
{ "index" : { "_index" : "east_ccs" } }
{"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268}
{ "index" : { "_index" : "east_ccs" } }
{"name": "The Handmaid'"'"'s Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}
{ "index" : { "_index" : "west_ccs" } }
{"name": "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328}
{ "index" : { "_index" : "west_ccs" } }
{"name": "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227}
$ python3 ccs_test.py
{'name': "The Handmaid's Tale", 'author': 'Margaret Atwood', 'release_date': '1985-06-01', 'page_count': 311}
{'name': '1984', 'author': 'George Orwell', 'release_date': '1985-06-01', 'page_count': 328}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment