awswrangler.opensearch.index_df¶
- awswrangler.opensearch.index_df(client: OpenSearch, df: DataFrame, index: str, doc_type: Optional[str] = None, **kwargs: Any) Dict[str, Any] ¶
Index all documents from a DataFrame to OpenSearch index.
- Parameters
client (OpenSearch) – instance of opensearchpy.OpenSearch to use.
df (pd.DataFrame) – Pandas DataFrame https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html
index (str) – Name of the index.
doc_type (str, optional) – Name of the document type (for Elasticsearch versions 5.x and earlier).
**kwargs – KEYWORD arguments forwarded to
index_documents()
which is used to execute the operation
- 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' ... )