Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from elasticsearch import Elasticsearch as ES
- # Connect to Elasticsearch
- es_client = ES(["http://elasticsearch:9200"])
- # Connect to OpenSearch
- os_client = ES(["http://opensearch:9200"])
- # Fetch all documents from Elasticsearch
- query = {"query": {"match_all": {}}}
- es_docs = es_client.search(index="my_index", body=query, size=10000)
- # Index documents in OpenSearch
- for doc in es_docs["hits"]["hits"]:
- os_client.index(index="my_index", body=doc["_source"])
Advertisement
Add Comment
Please, Sign In to add comment