org.modeshape.jcr.api.index

## Interface IndexManager

- All Known Subinterfaces:
    IndexManager

      public interface IndexManager

  An interface for programmatically adding or removing index providers and index definitions. Even though this is accessed via `Workspace.getIndexManager()`, like `NodeTypeManager` it represents a session's mechanism to define, alter, or remove index definitions for the whole repository (not just the session's `workspace`).

  To create an IndexDefinition:

  1. Call the `createIndexDefinitionTemplate()` method to obtain a new blank template
  2. Call the setter methods on the `IndexDefinitionTemplate` to make the template accurately describe the new or updated index definition
  3. For each of the index definition's columns, `create a column definition template` and call the setters to define the `property name` to which the column applies and the `type for the column`.
  4. Call the `IndexDefinitionTemplate.setColumnDefinitions(Iterable)` to assign the column definitions to the index definition
  The resulting `IndexDefinitionTemplate`, which is also an `IndexDefinition`, can then be passed to the `registerIndex(IndexDefinition, boolean)` or `registerIndexes(IndexDefinition[], boolean)` methods to add/update the index definition.
  See Also:
    `Workspace.getIndexManager()`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `IndexColumnDefinitionTemplate` | `createIndexColumnDefinitionTemplate()` Create a new template that can be used to programmatically define a column on an index.
    `IndexDefinitionTemplate` | `createIndexDefinitionTemplate()` Create a new template that can be used to programmatically define an index.
    `Map<String,IndexDefinition>` | `getIndexDefinitions()` Get a map of the registered index definitions keyed by their names.
    `Set<String>` | `getProviderNames()` Get the names of the available index providers.
    `void` | `registerIndex(IndexDefinition indexDefinition, boolean allowUpdate)` Register a new definition for an index.
    `void` | `registerIndexes(IndexDefinition[] indexDefinitions, boolean allowUpdate)` Register new definitions for several indexes.
    `void` | `unregisterIndexes(String... indexNames)` Removes an existing index definition.

- - ### Method Detail

    - #### getProviderNames

          Set<String> getProviderNames()

      Get the names of the available index providers.
      Returns:
        the immutable set of provider names; never null but possibly empty

    - #### getIndexDefinitions

          Map<String,IndexDefinition> getIndexDefinitions()

      Get a map of the registered index definitions keyed by their names. The resulting map is immutable, but it is updated whenever an index definition is added, updated, or removed. To add an index, use `registerIndex(IndexDefinition, boolean)` or `registerIndexes(IndexDefinition[], boolean)`; to remove an index, use `unregisterIndexes(java.lang.String...)`.
      Returns:
        the index definitions; never null but possibly empty

    - #### registerIndex

          void registerIndex(IndexDefinition indexDefinition,
                           boolean allowUpdate)
                             throws InvalidIndexDefinitionException,
                                    IndexExistsException,
                                    RepositoryException

      Register a new definition for an index.
      Parameters:
        `indexDefinition` - the definition; may not be null
        `allowUpdate` - true if the definition can update or ovewrite an existing definition with the same name, or false if calling this method should result in an exception when the repository already contains a definition with the same name already exists
      Throws:
        `InvalidIndexDefinitionException` - if the new definition is invalid
        `IndexExistsException` - if `allowUpdate` is `false` and the `IndexDefinition` specifies a node type name that is already registered.
        `RepositoryException` - if there is a problem registering the new definition, or if an existing index

    - #### registerIndexes

          void registerIndexes(IndexDefinition[] indexDefinitions,
                             boolean allowUpdate)
                               throws InvalidIndexDefinitionException,
                                      IndexExistsException,
                                      RepositoryException

      Register new definitions for several indexes.
      Parameters:
        `indexDefinitions` - the definitions; may not be null
        `allowUpdate` - true if each of the definition can update or ovewrite an existing definition with the same name, or false if calling this method should result in an exception when the repository already contains any definition with names that match the supplied definitions
      Throws:
        `InvalidIndexDefinitionException` - if the new definition is invalid
        `IndexExistsException` - if `allowUpdate` is `false` and the `IndexDefinition` specifies a node type name that is already registered.
        `RepositoryException` - if there is a problem registering the new definition, or if an existing index

    - #### unregisterIndexes

          void unregisterIndexes(String... indexNames)
                                 throws NoSuchIndexException,
                                        RepositoryException

      Removes an existing index definition.
      Parameters:
        `indexNames` - the names of the index definition to be removed; may not be null
      Throws:
        `NoSuchIndexException` - there is no index with the supplied name
        `RepositoryException` - if there is a problem registering the new definition, or if an existing index

    - #### createIndexDefinitionTemplate

          IndexDefinitionTemplate createIndexDefinitionTemplate()

      Create a new template that can be used to programmatically define an index.
      Returns:
        the new template; may not be null

    - #### createIndexColumnDefinitionTemplate

          IndexColumnDefinitionTemplate createIndexColumnDefinitionTemplate()

      Create a new template that can be used to programmatically define a column on an index.
      Returns:
        the new template; may not be null

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.