Interface SearchSchemaManager


  • public interface SearchSchemaManager
    The entry point for explicit schema management operations: creating indexes, dropping them, validating them, ...

    A SearchSchemaManager targets a pre-defined set of indexed types (and their indexes).

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void createIfMissing()
      Creates missing indexes and their schema, but does not touch existing indexes and assumes their schema is correct without validating it.
      void createOrUpdate()
      Creates missing indexes and their schema, and updates the schema of existing indexes if possible.
      void createOrValidate()
      Creates missing indexes and their schema, and validates the schema of existing indexes.
      void dropAndCreate()
      Drops existing indexes and re-creates them and their schema.
      void dropIfExisting()
      Drops existing indexes.
      void validate()
      Does not change indexes nor their schema, but checks that indexes exist and validates their schema.
    • Method Detail

      • validate

        void validate()
        Does not change indexes nor their schema, but checks that indexes exist and validates their schema.

        An exception will be thrown if:

        • Indexes are missing
        • OR, with Elasticsearch only, indexes exist but their schema does not match the requirements of the Hibernate Search mapping: missing fields, fields with incorrect type, missing analyzer definitions or normalizer definitions, ...

        Warning: with the Lucene backend, validation is limited to checking that the indexes exist, because local Lucene indexes don't have a schema.

      • createIfMissing

        void createIfMissing()
        Creates missing indexes and their schema, but does not touch existing indexes and assumes their schema is correct without validating it.

        Note that creating indexes or updating their schema will not populate or update the indexed data: a newly created index will always be empty. To populate indexes with pre-existing data, use mass indexing.

      • createOrValidate

        void createOrValidate()
        Creates missing indexes and their schema, and validates the schema of existing indexes.

        Note that creating indexes and their schema will not populate the indexed data: newly created indexes will always be empty. To populate indexes with pre-existing data, use mass indexing.

        With Elasticsearch only, an exception will be thrown on startup if some indexes already exist but their schema does not match the requirements of the Hibernate Search mapping: missing fields, fields with incorrect type, missing analyzer definitions or normalizer definitions, ...

        Warning: with the Lucene backend, validation is limited to checking that the indexes exist, because local Lucene indexes don't have a schema.

      • createOrUpdate

        void createOrUpdate()
        Creates missing indexes and their schema, and updates the schema of existing indexes if possible.

        Note that creating indexes or updating their schema will not populate or update the indexed data: newly created indexes will always be empty. To populate indexes with pre-existing data, use mass indexing.

        Note: with the Lucene backend, schema update is a no-op, because local Lucene indexes don't have a schema.

        Warning: with the Elasticsearch backend, if analyzer/normalizer definitions have to be updated, the index will be closed automatically during the update.

        Warning: with the Elasticsearch backend, many scenarios can cause schema updates to fail: a field changed its type from string to integer, an analyzer definition changed, ... In such cases, the only workaround is to drop and re-create the index.

      • dropIfExisting

        void dropIfExisting()
        Drops existing indexes.

        Note that dropping indexes means losing all indexed data.

      • dropAndCreate

        void dropAndCreate()
        Drops existing indexes and re-creates them and their schema.

        Note that dropping indexes means losing all indexed data, and creating indexes will not populate them: the newly created index will always be empty. To populate indexes with pre-existing data, use mass indexing.