awswrangler.opensearch.create_index¶
- awswrangler.opensearch.create_index(client: OpenSearch, index: str, doc_type: Optional[str] = None, settings: Optional[Dict[str, Any]] = None, mappings: Optional[Dict[str, Any]] = 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 ... } ... } ... )