Skip to main content

Create Index Request

This request creates a new Elasticsearch index.

In order to use the CreateIndex request import the following:

import zio.elasticsearch.ElasticRequest.CreateIndexRequest
import zio.elasticsearch.ElasticRequest.createIndex

You can create a CreateIndex request using the createIndex method in the following manner:

// this import is required for using `IndexName`
import zio.elasticsearch._

val request: CreateIndexRequest = createIndex(name = IndexName("index"))

You can also create a CreateIndex request using the createIndex method with the specific definition in the following manner:

val request: CreateIndexRequest = createIndex(name = IndexName("index"), definition = """{ "mappings": { "properties": { "subDocumentList": { "type": "nested" } } } }""")

You can find more information about CreateIndex request here.