Interface IndexOperations
- All Known Implementing Classes:
AbstractIndexTemplate
,IndicesTemplate
public interface IndexOperations
The operations for the
Elasticsearch Index APIs.
IndexOperations are bound to an entity class or an IndexCoordinate by
IndexOperations are bound to an entity class or an IndexCoordinate by
ElasticsearchOperations.indexOps(IndexCoordinates)
or ElasticsearchOperations.indexOps(Class)
- Since:
- 4.0
- Author:
- Peter-Josef Meisch, Sascha Woo, George Popides
-
Method Summary
Modifier and TypeMethodDescriptionboolean
alias
(AliasActions aliasActions) Executes the givenAliasActions
.boolean
create()
Create an index.boolean
Create an index for given settings.boolean
Create an index for given settings and mapping.Creates the index mapping for the entity this IndexOperations is bound to.createMapping
(Class<?> clazz) Creates the index mapping for the given classCreates the index settings for the entity this IndexOperations is bound to.createSettings
(Class<?> clazz) Creates the index settings from the annotations on the given classboolean
Create an index with the settings and mapping defined for the entity this IndexOperations is bound to.boolean
delete()
Deletes the index thisIndexOperations
is bound todefault boolean
deleteTemplate
(String templateName) Deletes an index template using the legacy Elasticsearch interface (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).boolean
deleteTemplate
(DeleteTemplateRequest deleteTemplateRequest) Deletes an index template using the legacy Elasticsearch interface (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).boolean
exists()
Checks if the index this IndexOperations is bound to existsdefault boolean
existsTemplate
(String templateName) check if an index template exists using the legacy Elasticsearch interface.boolean
existsTemplate
(ExistsTemplateRequest existsTemplateRequest) check if an index template exists using the legacy Elasticsearch interface.getAliases
(String... aliasNames) gets information about aliasesgetAliasesForIndex
(String... indexNames) gets information about aliasesget the currentIndexCoordinates
.default List<IndexInformation>
Gets theIndexInformation
for the indices defined bygetIndexCoordinates()
.getInformation
(IndexCoordinates index) Gets theIndexInformation
for the indices defined by #index.Get mapping for an index defined by a class.Get the index settings.getSettings
(boolean includeDefaults) Get the index settings.default TemplateData
getTemplate
(String templateName) gets an index template using the legacy Elasticsearch interface.getTemplate
(GetTemplateRequest getTemplateRequest) gets an index template using the legacy Elasticsearch interface.default boolean
Writes the mapping to the index for the class this IndexOperations is bound to.default boolean
putMapping
(Class<?> clazz) Creates the index mapping for the given class and writes it to the index.boolean
putMapping
(Document mapping) writes a mapping to the indexboolean
putTemplate
(PutTemplateRequest putTemplateRequest) Creates an index template using the legacy Elasticsearch interface (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).void
refresh()
Refresh the index(es) this IndexOperations is bound to
-
Method Details
-
create
boolean create()Create an index.- Returns:
- true if the index was created
-
create
Create an index for given settings.- Parameters:
settings
- the index settings- Returns:
- true if the index was created
-
create
Create an index for given settings and mapping.- Parameters:
settings
- the index settingsmapping
- the index mapping- Returns:
- true if the index was created
- Since:
- 4.2
-
createWithMapping
boolean createWithMapping()Create an index with the settings and mapping defined for the entity this IndexOperations is bound to.- Returns:
- true if the index was created
- Since:
- 4.2
-
delete
boolean delete()Deletes the index thisIndexOperations
is bound to- Returns:
- true if the index was deleted
-
exists
boolean exists()Checks if the index this IndexOperations is bound to exists- Returns:
- true if the index exists
-
refresh
void refresh()Refresh the index(es) this IndexOperations is bound to -
createMapping
Document createMapping()Creates the index mapping for the entity this IndexOperations is bound to.- Returns:
- mapping object
-
createMapping
Creates the index mapping for the given class- Parameters:
clazz
- the clazz to create a mapping for- Returns:
- mapping object
-
putMapping
default boolean putMapping()Writes the mapping to the index for the class this IndexOperations is bound to.- Returns:
- true if the mapping could be stored
- Since:
- 4.1
-
putMapping
writes a mapping to the index- Parameters:
mapping
- the Document with the mapping definitions- Returns:
- true if the mapping could be stored
-
putMapping
Creates the index mapping for the given class and writes it to the index.- Parameters:
clazz
- the clazz to create a mapping for- Returns:
- true if the mapping could be stored
- Since:
- 4.1
-
getMapping
Get mapping for an index defined by a class.- Returns:
- the mapping
-
createSettings
Settings createSettings()Creates the index settings for the entity this IndexOperations is bound to.- Returns:
- a settings document.
- Since:
- 4.1
-
createSettings
Creates the index settings from the annotations on the given class- Parameters:
clazz
- the class to create the index settings from- Returns:
- a settings document.
- Since:
- 4.1
-
getSettings
Settings getSettings()Get the index settings.- Returns:
- the settings
-
getSettings
Get the index settings.- Parameters:
includeDefaults
- whether or not to include all the default settings- Returns:
- the settings
-
alias
Executes the givenAliasActions
.- Parameters:
aliasActions
- the actions to execute- Returns:
- if the operation is acknowledged by Elasticsearch
- Since:
- 4.1
-
getAliases
gets information about aliases -
getAliasesForIndex
gets information about aliases -
putTemplate
Creates an index template using the legacy Elasticsearch interface (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).- Parameters:
putTemplateRequest
- template request parameters- Returns:
- true if successful
- Since:
- 4.1
-
getTemplate
gets an index template using the legacy Elasticsearch interface.- Parameters:
templateName
- the template name- Returns:
- TemplateData, null if no template with the given name exists.
- Since:
- 4.1
-
getTemplate
gets an index template using the legacy Elasticsearch interface.- Parameters:
getTemplateRequest
- the request parameters- Returns:
- TemplateData, null if no template with the given name exists.
- Since:
- 4.1
-
existsTemplate
check if an index template exists using the legacy Elasticsearch interface.- Parameters:
templateName
- the template name- Returns:
- true if the index exists
- Since:
- 4.1
-
existsTemplate
check if an index template exists using the legacy Elasticsearch interface.- Parameters:
existsTemplateRequest
- the request parameters- Returns:
- true if the index exists
- Since:
- 4.1
-
deleteTemplate
Deletes an index template using the legacy Elasticsearch interface (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).- Parameters:
templateName
- the template name- Returns:
- true if successful
- Since:
- 4.1
-
deleteTemplate
Deletes an index template using the legacy Elasticsearch interface (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).- Parameters:
deleteTemplateRequest
- template request parameters- Returns:
- true if successful
- Since:
- 4.1
-
getInformation
Gets theIndexInformation
for the indices defined bygetIndexCoordinates()
.- Returns:
- a list of
IndexInformation
- Since:
- 4.2
-
getInformation
Gets theIndexInformation
for the indices defined by #index.- Parameters:
index
- defines the index names to get the information for- Returns:
- a list of
IndexInformation
- Since:
- 4.2
-
getIndexCoordinates
IndexCoordinates getIndexCoordinates()get the currentIndexCoordinates
. These may change over time when the entity class has a SpEL constructed index name. When this IndexOperations is not bound to a class, the bound IndexCoordinates are returned.- Returns:
- IndexCoordinates
- Since:
- 4.1
-