awswrangler.opensearch.index_df

awswrangler.opensearch.index_df(client: opensearchpy.client.OpenSearch, df: pandas.core.frame.DataFrame, index: str, doc_type: Optional[str] = None, **kwargs: Any) Dict[str, Any]

Index all documents from a DataFrame to OpenSearch index.

Parameters
Returns

Response payload https://opensearch.org/docs/opensearch/rest-api/document-apis/bulk/#response.

Return type

Dict[str, Any]

Examples

Writing rows of DataFrame

>>> import awswrangler as wr
>>> import pandas as pd
>>> client = wr.opensearch.connect(host='DOMAIN-ENDPOINT')
>>> wr.opensearch.index_df(
...     client=client,
...     df=pd.DataFrame([{'_id': '1'}, {'_id': '2'}, {'_id': '3'}]),
...     index='sample-index1'
... )