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
|None
) – Name of the document type (for Elasticsearch versions 5.x and earlier).settings (
dict
[str
,Any
] |None
) – Index settings https://opensearch.org/docs/opensearch/rest-api/create-index/#index-settingsmappings (
dict
[str
,Any
] |None
) – Index mappings https://opensearch.org/docs/opensearch/rest-api/create-index/#mappings
- Return type:
dict
[str
,Any
]- Returns:
OpenSearch rest api response https://opensearch.org/docs/opensearch/rest-api/create-index/#response.
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 ... } ... } ... )