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:
client (OpenSearch) – instance of opensearchpy.OpenSearch to use.
index (str) – Name of the index.
doc_type (str, optional) – Name of the document type (for Elasticsearch versions 5.x and earlier).
settings (Dict[str, Any], optional) – Index settings https://opensearch.org/docs/opensearch/rest-api/create-index/#index-settings
mappings (Dict[str, Any], optional) – Index mappings https://opensearch.org/docs/opensearch/rest-api/create-index/#mappings
- 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 ... } ... } ... )