pythonamazon-web-serviceselasticsearchopensearch

How to upload a csv to aws opensearch?


I ran into this https://www.npmjs.com/package/elasticsearch-csv, via this plugin one can directly upload a csv and index it in elastic search. is there something similar for aws opensearch? I realize there is a python package - opensearchpy.

that can upload in bulk. other than this , can one directly push/upload a csv file?

from opensearchpy import OpenSearch

client = OpenSearch(...)

docs = '''
{"index": {"_index": "index-2022-06-08", "_id": "1"}}
{"name": "foo"} 
{"index": {"_index": "index-2022-06-09", "_id": "2"}}
{"name": "bar"}
{"index": {"_index": "index-2022-06-10", "_id": "3"}}
{"name": "baz"}
'''

response = client.bulk(docs)
if response["errors"]:
    print(f"There were errors!")
else:
    print(f"Bulk-inserted {len(response['items'])} items.")

Solution

  • There isn't an official package or plugin like Elastic Search for OpenSearch that allows you to upload a CSV file directly to AWS OpenSearch (formerly Amazon Elasticsearch) and index its contents.