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 ElasticsearchOperations.indexOps(IndexCoordinates) or ElasticsearchOperations.indexOps(Class)
Since:
4.0
Author:
Peter-Josef Meisch, Sascha Woo, George Popides
  • Method Details

    • create

      boolean create()
      Create an index.
      Returns:
      true if the index was created
    • create

      boolean create(Map<String,Object> settings)
      Create an index for given settings.
      Parameters:
      settings - the index settings
      Returns:
      true if the index was created
    • create

      boolean create(Map<String,Object> settings, Document mapping)
      Create an index for given settings and mapping.
      Parameters:
      settings - the index settings
      mapping - 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 this IndexOperations 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

      Document createMapping(Class<?> clazz)
      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

      boolean putMapping(Document mapping)
      writes a mapping to the index
      Parameters:
      mapping - the Document with the mapping definitions
      Returns:
      true if the mapping could be stored
    • putMapping

      default boolean putMapping(Class<?> clazz)
      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

      Map<String,Object> 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

      Settings createSettings(Class<?> clazz)
      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

      Settings getSettings(boolean includeDefaults)
      Get the index settings.
      Parameters:
      includeDefaults - whether or not to include all the default settings
      Returns:
      the settings
    • alias

      boolean alias(AliasActions aliasActions)
      Executes the given AliasActions.
      Parameters:
      aliasActions - the actions to execute
      Returns:
      if the operation is acknowledged by Elasticsearch
      Since:
      4.1
    • getAliases

      Map<String,Set<AliasData>> getAliases(String... aliasNames)
      gets information about aliases
      Parameters:
      aliasNames - alias names, must not be null
      Returns:
      a Map from index names to AliasData for that index
      Since:
      4.1
    • getAliasesForIndex

      Map<String,Set<AliasData>> getAliasesForIndex(String... indexNames)
      gets information about aliases
      Parameters:
      indexNames - index names, must not be null
      Returns:
      a Map from index names to AliasData for that index
      Since:
      4.1
    • putTemplate

      boolean 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).
      Parameters:
      putTemplateRequest - template request parameters
      Returns:
      true if successful
      Since:
      4.1
    • getTemplate

      @Nullable default TemplateData getTemplate(String templateName)
      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

      @Nullable TemplateData getTemplate(GetTemplateRequest getTemplateRequest)
      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

      default boolean existsTemplate(String templateName)
      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

      boolean existsTemplate(ExistsTemplateRequest existsTemplateRequest)
      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

      default 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).
      Parameters:
      templateName - the template name
      Returns:
      true if successful
      Since:
      4.1
    • deleteTemplate

      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).
      Parameters:
      deleteTemplateRequest - template request parameters
      Returns:
      true if successful
      Since:
      4.1
    • getInformation

      default List<IndexInformation> getInformation()
      Gets the IndexInformation for the indices defined by getIndexCoordinates().
      Returns:
      a list of IndexInformation
      Since:
      4.2
    • getInformation

      List<IndexInformation> getInformation(IndexCoordinates index)
      Gets the IndexInformation 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 current IndexCoordinates. 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