awswrangler.opensearch.create_index

awswrangler.opensearch.create_index(client: opensearchpy.OpenSearch, index: str, doc_type: str | None = None, settings: dict[str, Any] | None = None, mappings: dict[str, Any] | None = None) dict[str, Any]

Create an index.

Parameters:
Returns:

OpenSearch rest api response https://opensearch.org/docs/opensearch/rest-api/create-index/#response.

Return type:

Dict[str, Any]

Examples

Creating an index.

>>> import awswrangler as wr
>>> client = wr.opensearch.connect(host='DOMAIN-ENDPOINT')
>>> response = wr.opensearch.create_index(
...     client=client,
...     index="sample-index1",
...     mappings={
...        "properties": {
...          "age":  { "type" : "integer" }
...        }
...     },
...     settings={
...         "index": {
...             "number_of_shards": 2,
...             "number_of_replicas": 1
...          }
...     }
... )