diff --git a/src/main/asciidoc/reference/elasticsearch-object-mapping.adoc b/src/main/asciidoc/reference/elasticsearch-object-mapping.adoc index 43d1b3bb6..de252e2c7 100644 --- a/src/main/asciidoc/reference/elasticsearch-object-mapping.adoc +++ b/src/main/asciidoc/reference/elasticsearch-object-mapping.adoc @@ -34,7 +34,7 @@ The following annotations are available: ** `replicas`: the number of replicas for the index. ** `refreshIntervall`: Refresh interval for the index. Used for index creation. Default value is _"1s"_. ** `indexStoreType`: Index storage type for the index. Used for index creation. Default value is _"fs"_. -** `createIndex`: Configuration whether to create an index on repository bootstrapping. Default value is _true_. +** `createIndex`: flag whether to create an index on repository bootstrapping. Default value is _true_. See <> ** `versionType`: Configuration of version management. Default value is _EXTERNAL_. * `@Id`: Applied at the field level to mark the field used for identity purpose. diff --git a/src/main/asciidoc/reference/elasticsearch-operations.adoc b/src/main/asciidoc/reference/elasticsearch-operations.adoc index 49580288b..34a752c2b 100644 --- a/src/main/asciidoc/reference/elasticsearch-operations.adoc +++ b/src/main/asciidoc/reference/elasticsearch-operations.adoc @@ -17,6 +17,18 @@ The default implementations of the interfaces offer: * A rich query and criteria api. * Resource management and Exception translation. +[NOTE] +==== +.Index management and automatic creation of indices and mappings. + +The `IndexOperations` interface and the provided implementation which can be obtained from an `ElasticsearchOperations` instance - for example with a call to `operations.indexOps(clazz)`- give the user the ability to create indices, put mappings or store template and alias information in the Elasticsearch cluster. + +**None of these operations are done automatically** by the implementations of `IndexOperations` or `ElasticsearchOperations`. It is the user's responsibility to call the methods. + +There is support for automatic creation of indices and writing the mappings when using Spring Data Elasticsearch repositories, see <> + +==== + [[elasticsearch.operations.template]] == ElasticsearchTemplate diff --git a/src/main/asciidoc/reference/elasticsearch-repositories.adoc b/src/main/asciidoc/reference/elasticsearch-repositories.adoc index 60c186967..6fba3fd3a 100644 --- a/src/main/asciidoc/reference/elasticsearch-repositories.adoc +++ b/src/main/asciidoc/reference/elasticsearch-repositories.adoc @@ -26,6 +26,13 @@ class Book { ---- ==== +[[elasticsearch.repositories.autocreation]] +== Automatic creation of indices with the corresponding mapping + +The `@Document` annotation has an argument `createIndex`. If this argument is set to true - which is the default value - Spring Data Elasticsearch will during bootstrapping the repository support on application startup check if the index defined by the `@Document` annotation exists. + +If it does not exist, the index will be created and the mappings derived from the entity's annotations (see <>) will be written to the newly created index. + include::elasticsearch-repository-queries.adoc[leveloffset=+1] include::reactive-elasticsearch-repositories.adoc[leveloffset=+1]