Use Hibernate Search in Standalone mode with Elasticsearch/OpenSearch

Hibernate Search Standalone indexes entities in an Elasticsearch or OpenSearch cluster without requiring Hibernate ORM. This guide explains how to index entities and query the cluster using the Hibernate Search API.

If you want to index Hibernate ORM entities, see Use Hibernate Search with Hibernate ORM and Elasticsearch/OpenSearch instead.

Requisitos previos

To complete this guide, you need:

  • Roughly 20 minutes

  • An IDE

  • JDK 21+ installed with JAVA_HOME configured appropriately

  • Apache Maven 3.9.16

  • A working container runtime (Docker or Podman)

  • Optionally the Quarkus CLI if you want to use it

  • Optionally Mandrel or GraalVM installed and configured appropriately if you want to build a native executable (or Docker if you use a native container build)

Arquitectura

The application described in this guide manages a simple library of authors and their books.

The entities are stored and indexed in an Elasticsearch cluster.

Solución

Follow the instructions in the next sections to create the application step by step. Alternatively, use the completed example.

Clone el repositorio Git: git clone -b development https://github.com/quarkusio/quarkus-quickstarts.git o descargue un archivo.

The solution is located in the hibernate-search-standalone-elasticsearch-quickstart directory.

The provided solution contains a few additional elements such as tests and testing infrastructure.

Creación del proyecto Maven

Create a new project with the following command:

CLI
quarkus create app org.acme:hibernate-search-standalone-elasticsearch-quickstart \
    --extension='hibernate-search-standalone-elasticsearch,rest-jackson' \
    --no-code
cd hibernate-search-standalone-elasticsearch-quickstart

To create a Gradle project, add the --gradle or --gradle-kotlin-dsl option.

For more information about how to install and use the Quarkus CLI, see the Quarkus CLI guide.

Maven
mvn io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=hibernate-search-standalone-elasticsearch-quickstart \
    -Dextensions='hibernate-search-standalone-elasticsearch,rest-jackson' \
    -DnoCode
cd hibernate-search-standalone-elasticsearch-quickstart

To create a Gradle project, add the -DbuildTool=gradle or -DbuildTool=gradle-kotlin-dsl option.

For Windows users:

  • If using cmd, (don’t use backward slash \ and put everything on the same line)

  • If using Powershell, wrap -D parameters in double quotes e.g. "-DprojectArtifactId=hibernate-search-standalone-elasticsearch-quickstart"

This command generates a Maven structure importing the following extensions:

  • Hibernate Search Standalone + Elasticsearch,

  • Quarkus REST (formerly RESTEasy Reactive) and Jackson.

If you already have a Quarkus project, add the hibernate-search-standalone-elasticsearch extension to it. Run the following command in your project base directory:

CLI
quarkus extension add hibernate-search-standalone-elasticsearch
Maven
./mvnw quarkus:add-extension -Dextensions='hibernate-search-standalone-elasticsearch'
Gradle
./gradlew addExtension --extensions='hibernate-search-standalone-elasticsearch'

This command adds the following dependency to your pom.xml:

pom.xml
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-hibernate-search-standalone-elasticsearch</artifactId>
</dependency>
build.gradle
implementation("io.quarkus:quarkus-hibernate-search-standalone-elasticsearch")

Creating the bare classes

Create the Book and Author classes in the model subpackage.

package org.acme.hibernate.search.elasticsearch.model;

import java.util.List;
import java.util.UUID;

public class Author {

    public UUID id; (1)

    public String firstName;

    public String lastName;

    public List<Book> books;

    public Author(UUID id, String firstName, String lastName, List<Book> books) {
        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
        this.books = books;
    }
}
1 This example uses public fields to keep the data class concise.

Private fields with getters and setters also work when the methods follow the JavaBeans naming convention, such as getSomething(), isSomething(), and setSomething(…​).

package org.acme.hibernate.search.elasticsearch.model;

import java.util.UUID;

public class Book {

    public UUID id;

    public String title;

    public Book(UUID id, String title) {
        this.id = id;
        this.title = title;
    }
}

Using Hibernate Search annotations

Add Hibernate Search annotations to enable full-text search for the classes.

Update the Author entity with the following content:

package org.acme.hibernate.search.elasticsearch.model;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.hibernate.search.engine.backend.types.Sortable;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IdProjection;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ProjectionConstructor;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.SearchEntity;

@SearchEntity (1)
@Indexed (2)
public class Author {

    @DocumentId (3)
    public UUID id;

    @FullTextField(analyzer = "name") (4)
    @KeywordField(name = "firstName_sort", sortable = Sortable.YES, normalizer = "sort") (5)
    public String firstName;

    @FullTextField(analyzer = "name")
    @KeywordField(name = "lastName_sort", sortable = Sortable.YES, normalizer = "sort")
    public String lastName;

    @IndexedEmbedded (6)
    public List<Book> books = new ArrayList<>();

    public Author(UUID id, String firstName, String lastName) {
        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
    }

    @ProjectionConstructor (7)
    public Author(@IdProjection UUID id, String firstName, String lastName, List<Book> books) {
        this( id, firstName, lastName );
        this.books = books;
    }
}
1 Mark the Author type as a entity type. This means that the Author type has its own distinct lifecycle (not tied to another type), and that every Author instance carries an immutable, unique identifier.
2 Mark the Author entity type as indexed with @Indexed, mapping it to the backend index where its instances are stored as documents.
3 Define a document identifier. The standalone mapper requires the document identifier to be mapped explicitly, here with @DocumentId.
4 The @FullTextField annotation declares a field in the index specifically tailored for full-text search. Define an analyzer to split and analyze tokens.
5 A property can map to multiple index fields. Field names must be unique, and a field is named after its property by default, so the additional keyword field is explicitly named firstName_sort. This keyword field indexes the value as a single token normalized by the sort normalizer. sortable = Sortable.YES enables sorting by this field.
6 The purpose of @IndexedEmbedded is to include the Book fields into the Author index. This example uses the default configuration, which includes all indexed fields of associated Book instances in the index. @IndexedEmbedded also supports nested documents through the structure = NESTED attribute. Use the includePaths or excludePaths attributes to control the fields included in the parent index.
7 Annotate a single constructor with @ProjectionConstructor so that an Author instance can be reconstructed from the content of the index.

Map books so that @IndexedEmbedded embeds fields in the index.

Open the Book class and include the content below.

package org.acme.hibernate.search.elasticsearch.model;

import java.util.UUID;

import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ProjectionConstructor;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.SearchEntity;

@SearchEntity (1)
public class Book {

    @KeywordField (2)
    public UUID id;

    @FullTextField(analyzer = "english") (3)
    public String title;

    @ProjectionConstructor (4)
    public Book(UUID id, String title) {
        this.id = id;
        this.title = title;
    }
}
1 Mark the Book type as a entity type, but do not use @Indexed because books do not need a dedicated index.
2 Index the book ID so that it can be projected.
3 Use @FullTextField with a different analyzer from Author.
4 As with Author, annotate a constructor with @ProjectionConstructor so that a Book instance can be reconstructed from the content of the index.

Analyzers and normalizers

Introducción

Analysis defines how text is processed when indexing or building search queries.

Analyzers split text into tokens (~ words) and filter them, for example, by converting text to lowercase and/or removing accents. Filters are applied one after the other, and an analyzer usually applies several of them.

Normalizers are a special type of analyzer that can only emit a single output token. They are especially useful for sorting or indexing keywords.

Search backends provide bundled analyzers, and you can develop analyzers for specific purposes.

For more information about the Elasticsearch analysis framework, see the Elasticsearch documentation.

Defining the analyzers used

The annotations on the entities in the preceding examples declare the following analyzers and normalizer:

@FullTextField(analyzer = "english")
@FullTextField(analyzer = "name")
@KeywordField(name = "lastName_sort", sortable = Sortable.YES, normalizer = "sort")

The example uses:

  • an analyzer called name for person names,

  • an analyzer called english for book titles,

  • a normalizer called sort for sort fields.

Define them in a configurer.

Setting up the analyzers

Create an implementation of ElasticsearchAnalysisConfigurer.

package org.acme.hibernate.search.elasticsearch.config;

import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext;
import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer;

import io.quarkus.hibernate.search.standalone.elasticsearch.SearchExtension;

@SearchExtension (1)
public class AnalysisConfigurer implements ElasticsearchAnalysisConfigurer {

    @Override
    public void configure(ElasticsearchAnalysisConfigurationContext context) {
        context.analyzer("name").custom() (2)
                .tokenizer("standard")
                .tokenFilters("asciifolding", "lowercase");

        context.analyzer("english").custom() (3)
                .tokenizer("standard")
                .tokenFilters("asciifolding", "lowercase", "porter_stem");

        context.normalizer("sort").custom() (4)
                .tokenFilters("asciifolding", "lowercase");
    }
}
1 Annotate the configurer implementation with the @SearchExtension qualifier to tell Quarkus it should be used in Hibernate Search Standalone, for all Elasticsearch indexes (by default).

The annotation can also target a specific backend (@SearchExtension(backend = "nameOfYourBackend")), index (@SearchExtension(index = "nameOfYourIndex")), or both (@SearchExtension(backend = "nameOfYourBackend", index = "nameOfYourIndex")).

2 This analyzer separates words on spaces, replaces non-ASCII characters with their ASCII counterparts, and converts text to lowercase. The examples use it for author names.
3 This analyzer also applies stemming, so a query for mystery finds indexed input containing mysteries. It is too aggressive for person names, but suitable for book titles.
4 This normalizer is used for sorting. Like the first analyzer, it removes accents and converts text to lowercase, but it produces the whole value as a single normalized token.

For more information about configuring analyzers, see this section of the reference documentation.

Implementing the REST service

Create the org.acme.hibernate.search.elasticsearch.LibraryResource class:

package org.acme.hibernate.search.elasticsearch;

import java.util.ArrayList;
import java.util.UUID;

import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.MediaType;

import org.acme.hibernate.search.elasticsearch.model.Author;
import org.acme.hibernate.search.elasticsearch.model.Book;

import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping;
import org.hibernate.search.mapper.pojo.standalone.session.SearchSession;

import org.jboss.resteasy.reactive.RestForm;
import org.jboss.resteasy.reactive.RestPath;

@Path("/library")
public class LibraryResource {

    @Inject
    SearchMapping searchMapping; (1)

    @PUT
    @Path("author")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public void addAuthor(@RestForm String firstName, @RestForm String lastName) {
        try (var searchSession = searchMapping.createSession()) { (2)
            Author author = new Author(UUID.randomUUID(), firstName, lastName, new ArrayList<>());
            searchSession.indexingPlan().add(author); (3)
        }
    }

    @GET
    @Path("author/{id}")
    public Author getAuthor(@RestPath UUID id) {
        try (var searchSession = searchMapping.createSession()) {
            return getAuthor(searchSession, id);
        }
    }

    private Author getAuthor(SearchSession searchSession, UUID id) {
        return searchSession.search(Author.class) (4)
                .where(f -> f.id().matching(id))
                .fetchSingleHit()
                .orElseThrow(NotFoundException::new);
    }

    @POST
    @Path("author/{id}")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public void updateAuthor(@RestPath UUID id, @RestForm String firstName, @RestForm String lastName) {
        try (var searchSession = searchMapping.createSession()) {
            Author author = getAuthor(searchSession, id); (5)
            author.firstName = firstName;
            author.lastName = lastName;
            searchSession.indexingPlan().addOrUpdate(author); (5)
        }
    }

    @DELETE
    @Path("author/{id}")
    public void deleteAuthor(@RestPath UUID id) {
        try (var searchSession = searchMapping.createSession()) {
            searchSession.indexingPlan().purge(Author.class, id, null); (6)
        }
    }

    @PUT
    @Path("author/{authorId}/book/")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public void addBook(@RestPath UUID authorId, @RestForm String title) {
        try (var searchSession = searchMapping.createSession()) {
            Author author = getAuthor(searchSession, authorId); (7)
            author.books.add(new Book(UUID.randomUUID(), title));
            searchSession.indexingPlan().addOrUpdate(author);
        }
    }

    @DELETE
    @Path("author/{authorId}/book/{bookId}")
    public void deleteBook(@RestPath UUID authorId, @RestPath UUID bookId) {
        try (var searchSession = searchMapping.createSession()) {
            Author author = getAuthor(searchSession, authorId); (7)
            author.books.removeIf(book -> book.id.equals(bookId));
            searchSession.indexingPlan().addOrUpdate(author);
        }
    }
}
1 Inject a Hibernate Search mapping, the main entry point to Hibernate Search APIs.
2 Create a Hibernate Search session to execute index operations.
3 To index a new Author, retrieve the session indexing plan and call add with the author instance.
4 To retrieve an Author from the index, execute a simple search by identifier.
5 To update an Author, retrieve it from the index, apply changes, retrieve the session indexing plan, and call addOrUpdate with the author instance.
6 To delete an Author by identifier, retrieve the session indexing plan and call purge with the author class and identifier.
7 Books are owned by authors: they are duplicated for each author, and their lifecycle is bound to the author. Adding or deleting a book updates the author.

The REST service provides basic CRUD operations through Hibernate Search APIs.

Add a search endpoint to LibraryResource.

First, add the following imports:

import java.util.List;
import java.util.Optional;

import org.jboss.resteasy.reactive.RestQuery;

Then, add the following method:

    @GET
    @Path("author/search")
    public List<Author> searchAuthors(@RestQuery String pattern, (1)
            @RestQuery Optional<Integer> size) {
        try (var searchSession = searchMapping.createSession()) { (2)
            return searchSession.search(Author.class) (3)
                    .where(f -> pattern == null || pattern.isBlank()
                            ? f.matchAll() (4)
                            : f.simpleQueryString()
                                    .fields("firstName", "lastName", "books.title").matching(pattern)) (5)
                    .sort(f -> f.field("lastName_sort").then().field("firstName_sort")) (6)
                    .fetchHits(size.orElse(20)); (7)
        }
    }
1 Use the org.jboss.resteasy.reactive.RestQuery annotation type to avoid repeating the parameter name.
2 Create a Hibernate Search session to execute index operations.
3 search(Author.class) specifies that the query targets the Author index.
4 When the pattern is empty, use a matchAll() predicate.
5 For a nonempty pattern, create a simpleQueryString() predicate targeting the firstName, lastName, and books.title fields.
6 Sort results by last name and then by first name, using the fields created for sorting.
7 Fetch the size top hits, or 20 by default. Paging is also supported.

The Hibernate Search DSL supports a significant subset of the Elasticsearch predicates, such as match, range, nested, phrase, and spatial predicates. Explore the DSL by using autocompletion in your IDE.

If the DSL is not sufficient, define a predicate directly with JSON.

Automatic data initialization

Import an initial dataset for the example.

Add the following imports to LibraryResource:

import jakarta.enterprise.event.Observes;

import io.quarkus.runtime.StartupEvent;

Then, add the following methods:

    void onStart(@Observes StartupEvent ev) { (1)
        // Index some test data if nothing exists
        try (var searchSession = searchMapping.createSession()) {
            if (0 < searchSession.search(Author.class) (2)
                    .where(f -> f.matchAll())
                    .fetchTotalHitCount()) {
                return;
            }
            for (Author author : initialDataSet()) { (3)
                searchSession.indexingPlan().add(author); (4)
            }
        }
    }

    private List<Author> initialDataSet() {
        return List.of(
                new Author(UUID.randomUUID(), "John", "Irving",
                        List.of(
                                new Book(UUID.randomUUID(), "The World According to Garp"),
                                new Book(UUID.randomUUID(), "The Hotel New Hampshire"),
                                new Book(UUID.randomUUID(), "The Cider House Rules"),
                                new Book(UUID.randomUUID(), "A Prayer for Owen Meany"),
                                new Book(UUID.randomUUID(), "Last Night in Twisted River"),
                                new Book(UUID.randomUUID(), "In One Person"),
                                new Book(UUID.randomUUID(), "Avenue of Mysteries"))),
                new Author(UUID.randomUUID(), "Paul", "Auster",
                        List.of(
                                new Book(UUID.randomUUID(), "The New York Trilogy"),
                                new Book(UUID.randomUUID(), "Mr. Vertigo"),
                                new Book(UUID.randomUUID(), "The Brooklyn Follies"),
                                new Book(UUID.randomUUID(), "Invisible"),
                                new Book(UUID.randomUUID(), "Sunset Park"),
                                new Book(UUID.randomUUID(), "4 3 2 1"))));
    }
1 Add a method that runs when the application starts.
2 Check whether the index already contains data; if so, return.
3 Generate the initial dataset.
4 For each author, add it to the index.

Configuración de la aplicación

Configure Hibernate Search in the Quarkus configuration file, application.properties.

Edit src/main/resources/application.properties and inject the following configuration:

quarkus.hibernate-search-standalone.mapping.structure=document (1)
quarkus.hibernate-search-standalone.elasticsearch.version=9 (2)
quarkus.hibernate-search-standalone.indexing.plan.synchronization.strategy=sync (3)

%prod.quarkus.hibernate-search-standalone.elasticsearch.hosts=localhost:9200 (4)
1 Configure the structure of the indexed entities.

In this application, the indexed Author entity is the root of a document. The author owns the associated books, which cannot be updated independently.

See quarkus.hibernate-search-standalone.mapping.structure for other options and more details.

2 Configure the Elasticsearch version.

Significant differences exist between Elasticsearch mapping syntax for different versions. Since the mapping is created at build time to reduce startup time, Hibernate Search cannot connect to the cluster to automatically detect the version. For OpenSearch, prefix the version with opensearch:; see OpenSearch compatibility.

3 This strategy waits until entities are searchable before it considers a write complete. In production, the default write-sync strategy provides better performance. Use sync when testing so that entities are immediately searchable.
4 In development and tests, Dev Services starts an Elasticsearch cluster automatically. In production, configure the Elasticsearch connection in the prod profile (%prod. prefix).

When Dev Services is used, the Elasticsearch schema is automatically dropped and re-created on each application startup in tests and development mode (unless quarkus.hibernate-search-standalone.schema-management.strategy is set explicitly).

If Dev Services cannot be used, set the following properties for similar behavior:

%dev,test.quarkus.hibernate-search-standalone.schema-management.strategy=drop-and-create

For more information about configuration of the Hibernate Search Standalone extension, refer to the Configuration Reference.

Creating a frontend

Add a simple web page to interact with LibraryResource. Quarkus automatically serves static resources located under the META-INF/resources directory. In the src/main/resources/META-INF/resources directory, overwrite the existing index.html file with the content from this index.html file.

Time to play with your application

Interact with the REST service:

  1. Start the Quarkus application:

    CLI
    quarkus dev
    Maven
    ./mvnw quarkus:dev
    Gradle
    ./gradlew --console=plain quarkusDev
  2. Open http://localhost:8080/ in a browser.

  3. Search for authors or book titles in the initial data set.

  4. Create authors and books, and then search for them.

All updates are automatically synchronized with the Elasticsearch cluster.

Building a native executable

Build a native executable:

CLI
quarkus build --native
Maven
./mvnw install -Dnative
Gradle
./gradlew build -Dquarkus.native.enabled=true

Native executable compilation consumes a large amount of memory.

Consider stopping the Elasticsearch container while building the native executable and restarting it afterward.

Run ./target/hibernate-search-standalone-elasticsearch-quickstart-1.0.0-SNAPSHOT-runner.

Open http://localhost:8080/ in a browser.

Startup is slower because the application indexes initial data.

Production applications typically do not perform this operation at every startup.

Dev Services (Configuration Free Datastores)

Quarkus Dev Services starts supported containers without configuration.

For Elasticsearch, Dev Services starts a container for the default Hibernate Search backend only. Hibernate Search Standalone also supports named backends, but Quarkus does not start or configure Dev Services containers for them. If quarkus.hibernate-search-standalone.elasticsearch.hosts is not configured, Quarkus starts and configures an Elasticsearch container when running tests or in dev mode.

When running the application in production, configure the Elasticsearch connection. To define production settings in application.properties while continuing to use Dev Services, use the %prod. profile for the Elasticsearch settings.

For more information, see the Dev Services for Elasticsearch guide.

Programmatic mapping

If, for some reason, adding Hibernate Search annotations to entities is not possible, mapping can be applied programmatically instead. Programmatic mapping is configured through the ProgrammaticMappingConfigurationContext that is exposed through a mapping configurer (StandalonePojoMappingConfigurer).

A mapping configurer (StandalonePojoMappingConfigurer) allows much more than just programmatic mapping capabilities. It also allows configuring annotation mapping, bridges, and more.

Below is an example of a mapping configurer that applies programmatic mapping:

package org.acme.hibernate.search.elasticsearch.config;

import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurationContext;
import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurer;
import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep;

import io.quarkus.hibernate.search.standalone.elasticsearch.SearchExtension;

@SearchExtension (1)
public class CustomMappingConfigurer implements StandalonePojoMappingConfigurer {

    @Override
    public void configure(StandalonePojoMappingConfigurationContext context) {
        TypeMappingStep type = context.programmaticMapping()    (2)
                .type(SomeIndexedEntity.class);                 (3)
        type.searchEntity();                                    (4)
        type.indexed()                                          (5)
                .index(SomeIndexedEntity.INDEX_NAME);           (6)
        type.property("id").documentId();                       (7)
        type.property("text").fullTextField();                  (8)
    }
}
1 Annotate the configurer implementation with the @SearchExtension qualifier to tell Quarkus it should be used by Hibernate Search Standalone.
2 Access the programmatic mapping context.
3 Create mapping step for the SomeIndexedEntity type.
4 Define SomeIndexedEntity as an entity type for Hibernate Search.
5 Define the SomeIndexedEntity entity as indexed.
6 Provide an index name to be used for the SomeIndexedEntity entity.
7 Define the document id property.
8 Define a full-text search field for the text property.

OpenSearch compatibility

Hibernate Search is compatible with both Elasticsearch and OpenSearch, but it assumes it is working with an Elasticsearch cluster by default.

To have Hibernate Search work with an OpenSearch cluster instead, prefix the configured version with opensearch:, as shown below.

quarkus.hibernate-search-standalone.elasticsearch.version=opensearch:3.5

All other configuration options and APIs are exactly the same as with Elasticsearch.

For more information about compatible Elasticsearch distributions and versions, see this section of the Hibernate Search reference documentation.

CDI integration

Injecting entry points

Inject Hibernate Search’s main entry point, SearchMapping, with CDI:

@Inject
SearchMapping searchMapping;

Plugging in custom components

The Quarkus extension for Hibernate Search Standalone will automatically inject components annotated with @SearchExtension into Hibernate Search.

The annotation can optionally target a specific backend (@SearchExtension(backend = "nameOfYourBackend")), index (@SearchExtension(index = "nameOfYourIndex")), or a combination of those (@SearchExtension(backend = "nameOfYourBackend", index = "nameOfYourIndex")), when it makes sense for the type of the component being injected.

This feature is available for the following component types:

org.hibernate.search.engine.reporting.FailureHandler

A component that should be notified of any failure occurring in a background process (mainly index operations).

Scope: one per application.

org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurer

A component used to configure the Hibernate Search mapping, in particular programmatically.

Scope: one or more per application.

See this section of this guide for more information.

org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy

A component used to configure how to synchronize between application threads and indexing.

Scope: one per application.

Can also be set to built-in implementations through quarkus.hibernate-search-standalone.indexing.plan.synchronization.strategy.

org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer

A component used to configure full-text analysis (for example, analyzers and normalizers).

Scope: one or more per backend.

See this section of this guide for more information.

org.hibernate.search.backend.elasticsearch.index.layout.IndexLayoutStrategy

A component used to configure the Elasticsearch layout, such as index names and index aliases.

Scope: one per backend.

Can also be set to built-in implementations through quarkus.hibernate-search-standalone.elasticsearch.layout.strategy.

Offline startup

By default, Hibernate Search sends a few requests to the Elasticsearch cluster on startup. If the Elasticsearch cluster is not necessarily up and running when Hibernate Search starts, this could cause a startup failure.

To prevent requests on startup, configure Hibernate Search as follows:

  1. Disable Elasticsearch version checks on startup by setting the configuration property quarkus.hibernate-search-standalone.elasticsearch.version-check.enabled to false.

  2. Disable schema management on startup by setting the configuration property quarkus.hibernate-search-standalone.schema-management.strategy to none.

With this configuration, Hibernate Search cannot index entities or run search queries until the Elasticsearch cluster becomes accessible.

If you disable automatic schema creation by setting quarkus.hibernate-search-standalone.schema-management.strategy to none, create the schema manually before the application persists or updates entities and executes search requests.

Loading

As an alternative to using Elasticsearch as a primary data store, this extension can also be used to index entities from another data store.

In this scenario, set quarkus.hibernate-search-standalone.mapping.structure to a value matching the structure of the primary data store.

Load entities from the other data store explicitly.

For more information about configuring loading, see the Hibernate Search reference documentation:

In Quarkus, define the entity loader mentioned in the Hibernate Search reference documentation as a CDI bean. Attach it to the relevant entities with @SearchEntity(loadingBinder = …​).

Management endpoint

Hibernate Search’s management endpoint is considered preview.

In preview, backward compatibility and presence in the ecosystem is not guaranteed. Specific improvements might require changing configuration or APIs, or even storage formats, and plans to become stable are under way. Feedback is welcome on our mailing list or as issues in our GitHub issue tracker.

The Hibernate Search extension provides an HTTP endpoint to reindex data through the management interface. By default, this endpoint is unavailable. Enable it with the following configuration properties:

quarkus.management.enabled=true (1)
quarkus.hibernate-search-standalone.management.enabled=true (2)
1 Enable the management interface.
2 Enable Hibernate Search Standalone specific management endpoints.

After enabling the management endpoints, reindex data through /q/hibernate-search/standalone/reindex. /q is the default management root path, and /hibernate-search/standalone/ is the default Hibernate Search root management path. Configure a different Hibernate Search root management path as follows:

quarkus.hibernate-search-standalone.management.root-path=custom-root-path (1)
1 Set a custom root path for the Hibernate Search management endpoint. With the default management root path, the reindex path becomes /q/custom-root-path/reindex.

This endpoint accepts POST requests with application/json content type only. If the request body is empty, all indexed entities are re-indexed.

Without that configuration, reindexing through the management endpoint (or through any other API) will fail.

To reindex only a subset of entities or configure the underlying mass indexer, include the following information in the request body:

{
  "filter": {
    "types": ["EntityName1", "EntityName2"] (1)
  },
  "massIndexer": {
    "typesToIndexInParallel": 1 (2)
  }
}
1 An array of entity names that should be re-indexed. If unspecified or empty, all entity types are re-indexed.
2 Sets the number of entity types to be indexed in parallel.

The full list of possible filters and available mass indexer configurations is presented in the example below.

{
  "filter": { (1)
    "types": ["EntityName1", "EntityName2"], (2)
    "tenants": ["tenant1", "tenant2"] (3)
  },
  "massIndexer": { (4)
    "typesToIndexInParallel": 1, (5)
    "threadsToLoadObjects": 6, (6)
    "batchSizeToLoadObjects": 10, (7)
    "mergeSegmentsOnFinish": false, (8)
    "mergeSegmentsAfterPurge": true, (9)
    "dropAndCreateSchemaOnStart": false, (10)
    "purgeAllOnStart": true (11)
  }
}
1 Filter object that limits the scope of reindexing.
2 An array of entity names that should be re-indexed. If unspecified or empty, all entity types are re-indexed.
3 An array of tenant IDs, in case of multi-tenancy. If unspecified or empty, all tenants are re-indexed.
4 Mass indexer configuration object.
5 Sets the number of entity types to be indexed in parallel.
6 Sets the number of threads to be used to load the root entities.
7 Sets the batch size used to load the root entities.
8 Whether each index is merged into a single segment after indexing.
9 Whether each index is merged into a single segment after the initial index purge, just before indexing.
10 Whether the indexes and their schema (if they exist) should be dropped and re-created before indexing.
11 Whether all entities are removed from the indexes before indexing.

All properties in the JSON are optional. Specify only the properties that are needed.

For more detailed information on mass indexer configuration see the corresponding section of the Hibernate Search reference documentation.

Submitting the reindexing request triggers indexing in the background. Mass indexing progress appears in the application logs. To wait for indexing to finish, add the wait_for=finished query parameter to the URL. The management endpoint returns a chunked response that reports when indexing starts and finishes.

Limitations

Further reading

If you are interested in learning more about Hibernate Search, the Hibernate team publishes an extensive reference documentation, as well as a page listing other relevant resources.

FAQ

Why Elasticsearch only?

Hibernate Search supports both a Lucene backend and an Elasticsearch backend.

For scalable applications, Quarkus supports the Elasticsearch backend.

Quarkus does not currently plan to support the Lucene backend, though there is an issue tracking progress on such an implementation in the Quarkiverse: quarkiverse/quarkus-hibernate-search-extras#180.

Configuration Reference for Hibernate Search Standalone

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Tipo

Por defecto

Whether Hibernate Search Standalone is enabled during the build.

If Hibernate Search is disabled during the build, all processing related to Hibernate Search will be skipped, but it will not be possible to activate Hibernate Search at runtime: quarkus.hibernate-search-standalone.active will default to false and setting it to true will lead to an error.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ENABLED

Show more

boolean

true

A bean reference to a component that should be notified of any failure occurring in a background process (mainly index operations).

The referenced bean must implement FailureHandler.

Instead of setting this configuration property, you can simply annotate your custom FailureHandler implementation with @SearchExtension and leave the configuration property unset: Hibernate Search will use the annotated implementation automatically. See this section for more information.

If this configuration property is set, it takes precedence over any @SearchExtension annotation.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_BACKGROUND_FAILURE_HANDLER

Show more

string

One or more bean references to the component(s) used to configure the Hibernate Search mapping, in particular programmatically.

The referenced beans must implement StandalonePojoMappingConfigurer.

See Programmatic mapping for an example on how mapping configurers can be used to apply programmatic mappings.

Instead of setting this configuration property, you can simply annotate your custom StandalonePojoMappingConfigurer implementations with @SearchExtension and leave the configuration property unset: Hibernate Search will use the annotated implementation automatically. See this section for more information.

If this configuration property is set, it takes precedence over any @SearchExtension annotation.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_MAPPING_CONFIGURER

Show more

list of string

The structure of the Hibernate Search entity mapping.

This must match the structure of the application model being indexed with Hibernate Search:

graph (default)

Entities indexed through Hibernate Search are nodes in an entity graph, i.e. an indexed entity is independent of other entities it references through associations, which can be updated independently of the indexed entity.

Associations between entities must be bi-directional: specifying the inverse side of associations through @AssociationInverseSide is required, unless reindexing is disabled for that association through @IndexingDependency(reindexOnUpdate = …​).

document

Entities indexed through Hibernate Search are the root of a document, i.e. an indexed entity "owns" other entities it references through associations, which cannot be updated independently of the indexed entity.

Associations between entities can be uni-directional: specifying the inverse side of associations through @AssociationInverseSide is not required.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_MAPPING_STRUCTURE

Show more

graphEntities indexed through Hibernate Search are nodes in an entity graph. With this structure\: * An indexed entity is independent of other entities it references through associations, which can be updated independently of the indexed entity; in particular they may be passed to {@link org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan#addOrUpdate(Object)}. * Therefore, when an entity changes, Hibernate Search may need to resolve other entities to reindex, which means in particular that associations between entities must be bi-directional\: specifying the inverse side of associations through @AssociationInverseSide is required, unless reindexing is disabled for that association through @IndexingDependency(reindexOnUpdate = …​). See also link\:https://docs.hibernate.org/search/9.0/reference/en-US/html_single/#mapping-reindexing-associationinverseside\]@AssociationInverseSide] link\:https://docs.hibernate.org/search/9.0/reference/en-US/html_single/#mapping-reindexing-reindexonupdate\]@IndexingDependency(reindexOnUpdate = …​)]., documentEntities indexed through Hibernate Search are the root of a document. With this structure\: * An indexed entity "owns" other entities it references through associations, which cannot be updated independently of the indexed entity; in particular they cannot be passed to {@link org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan#addOrUpdate(Object)}. * Therefore, when an entity changes, Hibernate Search doesn’t need to resolve other entities to reindex, which means in particular that associations between entities can be uni-directional\: specifying the inverse side of associations through @AssociationInverseSide is not required. See also link\:https://docs.hibernate.org/search/9.0/reference/en-US/html_single/#mapping-reindexing-associationinverseside\]@AssociationInverseSide].

graphEntities indexed through Hibernate Search are nodes in an entity graph. With this structure\: * An indexed entity is independent of other entities it references through associations, which can be updated independently of the indexed entity; in particular they may be passed to {@link org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan#addOrUpdate(Object)}. * Therefore, when an entity changes, Hibernate Search may need to resolve other entities to reindex, which means in particular that associations between entities must be bi-directional\: specifying the inverse side of associations through @AssociationInverseSide is required, unless reindexing is disabled for that association through @IndexingDependency(reindexOnUpdate = …​). See also link\:https://docs.hibernate.org/search/9.0/reference/en-US/html_single/#mapping-reindexing-associationinverseside\]@AssociationInverseSide] link\:https://docs.hibernate.org/search/9.0/reference/en-US/html_single/#mapping-reindexing-reindexonupdate\]@IndexingDependency(reindexOnUpdate = …​)].

Whether Hibernate Search Standalone should be active at runtime.

If Hibernate Search Standalone is not active, it won’t start with the application, and accessing the SearchMapping for search or other operations will not be possible.

Note that if Hibernate Search Standalone is disabled (i.e. quarkus.hibernate-search-standalone.enabled is set to false), it won’t be active, and setting this property to true will fail.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ACTIVE

Show more

boolean

'true' if Hibernate Search Standalone is enabled; 'false' otherwise

The schema management strategy, controlling how indexes and their schema are created, updated, validated or dropped on startup and shutdown.

Available values:

Strategy

Definition

none

Do nothing: assume that indexes already exist and that their schema matches Hibernate Search’s expectations.

validate

Validate that indexes exist and that their schema matches Hibernate Search’s expectations.

If it does not, throw an exception, but make no attempt to fix the problem.

create

For indexes that do not exist, create them along with their schema.

For indexes that already exist, do nothing: assume that their schema matches Hibernate Search’s expectations.

create-or-validate (default unless using Dev Services)

For indexes that do not exist, create them along with their schema.

For indexes that already exist, validate that their schema matches Hibernate Search’s expectations.

If it does not, throw an exception, but make no attempt to fix the problem.

create-or-update

For indexes that do not exist, create them along with their schema.

For indexes that already exist, validate that their schema matches Hibernate Search’s expectations; if it does not match expectations, try to update it.

This strategy is unfit for production environments, due to several important limitations, but can be useful when developing.

drop-and-create

For indexes that do not exist, create them along with their schema.

For indexes that already exist, drop them, then create them along with their schema.

drop-and-create-and-drop (default when using Dev Services)

For indexes that do not exist, create them along with their schema.

For indexes that already exist, drop them, then create them along with their schema.

Also, drop indexes and their schema on shutdown.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_SCHEMA_MANAGEMENT_STRATEGY

Show more

none, validate, create, create-or-validate, create-or-update, drop-and-create, drop-and-create-and-drop

drop-and-create-and-drop when using Dev Services; create-or-validate otherwise

How to synchronize between application threads and indexing, in particular when relying on (implicit) listener-triggered indexing on entity change, but also when using a SearchIndexingPlan explicitly.

Defines how complete indexing should be before resuming the application thread after a SearchSession is closed.

Available values:

Strategy

Throughput

Guarantees when the application thread resumes

Changes applied

Changes safe from crash/power loss

Changes visible on search

async

Best

write-sync (default)

Medium

read-sync

Medium to worst

sync

Worst

This property also accepts a bean reference to a custom implementations of IndexingPlanSynchronizationStrategy.

Instead of setting this configuration property, you can simply annotate your custom IndexingPlanSynchronizationStrategy implementation with @SearchExtension and leave the configuration property unset: Hibernate Search will use the annotated implementation automatically. If this configuration property is set, it takes precedence over any @SearchExtension annotation.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_INDEXING_PLAN_SYNCHRONIZATION_STRATEGY

Show more

string

write-sync

Configuration for Elasticsearch/OpenSearch backends

Tipo

Por defecto

quarkus.hibernate-search-standalone.elasticsearch."backend-name".version

The version of Elasticsearch used in the cluster.

As the schema is generated without a connection to the server, this item is mandatory.

It doesn’t have to be the exact version (it can be 7 or 7.1 for instance) but it has to be sufficiently precise to choose a model dialect (the one used to generate the schema) compatible with the protocol dialect (the one used to communicate with Elasticsearch).

There’s no rule of thumb here as it depends on the schema incompatibilities introduced by Elasticsearch versions. In any case, if there is a problem, you will have an error when Hibernate Search tries to connect to the cluster.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_VERSION

Show more

ElasticsearchVersion

quarkus.hibernate-search-standalone.elasticsearch."backend-name".schema-management.settings-file

Path to a file in the classpath holding custom index settings to be included in the index definition when creating an Elasticsearch index.

The provided settings will be merged with those generated by Hibernate Search, including analyzer definitions. When analysis is configured both through an analysis configurer and these custom settings, the behavior is undefined; it should not be relied upon.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_SCHEMA_MANAGEMENT_SETTINGS_FILE

Show more

string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".schema-management.mapping-file

Path to a file in the classpath holding a custom index mapping to be included in the index definition when creating an Elasticsearch index.

The file does not need to (and generally shouldn’t) contain the full mapping: Hibernate Search will automatically inject missing properties (index fields) in the given mapping.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_SCHEMA_MANAGEMENT_MAPPING_FILE

Show more

string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".analysis.configurer

One or more bean references to the component(s) used to configure full text analysis (e.g. analyzers, normalizers).

The referenced beans must implement ElasticsearchAnalysisConfigurer.

See Setting up the analyzers for more information.

Instead of setting this configuration property, you can simply annotate your custom ElasticsearchAnalysisConfigurer implementations with @SearchExtension and leave the configuration property unset: Hibernate Search will use the annotated implementation automatically. See this section for more information.

If this configuration property is set, it takes precedence over any @SearchExtension annotation.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_ANALYSIS_CONFIGURER

Show more

list of string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".hosts

The list of hosts of the Elasticsearch servers.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_HOSTS

Show more

list of string

localhost:9200

quarkus.hibernate-search-standalone.elasticsearch."backend-name".protocol

The protocol to use when contacting Elasticsearch servers. Set to "https" to enable SSL/TLS.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_PROTOCOL

Show more

httpUse clear-text HTTP, with SSL/TLS disabled., httpsUse HTTPS, with SSL/TLS enabled.

httpUse clear-text HTTP, with SSL/TLS disabled.

quarkus.hibernate-search-standalone.elasticsearch."backend-name".username

The username used for authentication.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_USERNAME

Show more

string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".password

The password used for authentication.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_PASSWORD

Show more

string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".connection-timeout

The timeout when establishing a connection to an Elasticsearch server.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_CONNECTION_TIMEOUT

Show more

Duration 

1S

quarkus.hibernate-search-standalone.elasticsearch."backend-name".read-timeout

The timeout when reading responses from an Elasticsearch server.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_READ_TIMEOUT

Show more

Duration 

30S

quarkus.hibernate-search-standalone.elasticsearch."backend-name".request-timeout

The timeout when executing a request to an Elasticsearch server.

This includes the time needed to wait for a connection to be available, send the request and read the response.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_REQUEST_TIMEOUT

Show more

Duration 

quarkus.hibernate-search-standalone.elasticsearch."backend-name".max-connections

The maximum number of connections to all the Elasticsearch servers.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_MAX_CONNECTIONS

Show more

int

40

quarkus.hibernate-search-standalone.elasticsearch."backend-name".max-connections-per-route

The maximum number of connections per Elasticsearch server.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_MAX_CONNECTIONS_PER_ROUTE

Show more

int

20

quarkus.hibernate-search-standalone.elasticsearch."backend-name".discovery.enabled

Defines if automatic discovery is enabled.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_DISCOVERY_ENABLED

Show more

boolean

false

quarkus.hibernate-search-standalone.elasticsearch."backend-name".discovery.refresh-interval

Refresh interval of the node list.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_DISCOVERY_REFRESH_INTERVAL

Show more

Duration 

10S

quarkus.hibernate-search-standalone.elasticsearch."backend-name".thread-pool.size

The size of the thread pool assigned to the backend.

Note that number is per backend, not per index. Adding more indexes will not add more threads.

As all operations happening in this thread-pool are non-blocking, raising its size above the number of processor cores available to the JVM will not bring noticeable performance benefit. The only reason to alter this setting would be to reduce the number of threads; for example, in an application with a single index with a single indexing queue, running on a machine with 64 processor cores, you might want to bring down the number of threads.

Defaults to the number of processor cores available to the JVM on startup.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_THREAD_POOL_SIZE

Show more

int

quarkus.hibernate-search-standalone.elasticsearch."backend-name".query.shard-failure.ignore

Whether partial shard failures are ignored (true) or lead to Hibernate Search throwing an exception (false).

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_QUERY_SHARD_FAILURE_IGNORE

Show more

boolean

false

quarkus.hibernate-search-standalone.elasticsearch."backend-name".version-check.enabled

Whether Hibernate Search should check the version of the Elasticsearch cluster on startup.

Set to false if the Elasticsearch cluster may not be available on startup.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_VERSION_CHECK_ENABLED

Show more

boolean

true

quarkus.hibernate-search-standalone.elasticsearch."backend-name".schema-management.required-status

The minimal Elasticsearch cluster status required on startup.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_SCHEMA_MANAGEMENT_REQUIRED_STATUS

Show more

green, yellow, red

yellow

quarkus.hibernate-search-standalone.elasticsearch."backend-name".schema-management.required-status-wait-timeout

How long we should wait for the status before failing the bootstrap.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_SCHEMA_MANAGEMENT_REQUIRED_STATUS_WAIT_TIMEOUT

Show more

Duration 

10S

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexing.queue-count

The number of indexing queues assigned to each index.

Higher values will lead to more connections being used in parallel, which may lead to higher indexing throughput, but incurs a risk of overloading Elasticsearch, i.e. of overflowing its HTTP request buffers and tripping circuit breakers, leading to Elasticsearch giving up on some request and resulting in indexing failures.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXING_QUEUE_COUNT

Show more

int

10

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexing.queue-size

The size of indexing queues.

Lower values may lead to lower memory usage, especially if there are many queues, but values that are too low will reduce the likeliness of reaching the max bulk size and increase the likeliness of application threads blocking because the queue is full, which may lead to lower indexing throughput.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXING_QUEUE_SIZE

Show more

int

1000

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexing.max-bulk-size

The maximum size of bulk requests created when processing indexing queues.

Higher values will lead to more documents being sent in each HTTP request sent to Elasticsearch, which may lead to higher indexing throughput, but incurs a risk of overloading Elasticsearch, i.e. of overflowing its HTTP request buffers and tripping circuit breakers, leading to Elasticsearch giving up on some request and resulting in indexing failures.

Note that raising this number above the queue size has no effect, as bulks cannot include more requests than are contained in the queue.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXING_MAX_BULK_SIZE

Show more

int

100

quarkus.hibernate-search-standalone.elasticsearch."backend-name".layout.strategy

A bean reference to the component used to configure the Elasticsearch layout: index names, index aliases, …​

The referenced bean must implement IndexLayoutStrategy.

Available built-in implementations:

simple

The default, future-proof strategy: if the index name in Hibernate Search is myIndex, this strategy will create an index named myindex-000001, an alias for write operations named myindex-write, and an alias for read operations named myindex-read.

no-alias

A strategy without index aliases, mostly useful on legacy clusters: if the index name in Hibernate Search is myIndex, this strategy will create an index named myindex, and will not use any alias.

Instead of setting this configuration property, you can simply annotate your custom IndexLayoutStrategy implementation with @SearchExtension and leave the configuration property unset: Hibernate Search will use the annotated implementation automatically. See this section for more information.

If this configuration property is set, it takes precedence over any @SearchExtension annotation.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_LAYOUT_STRATEGY

Show more

string

Per-index configuration overrides

Tipo

Por defecto

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".schema-management.settings-file

Path to a file in the classpath holding custom index settings to be included in the index definition when creating an Elasticsearch index.

The provided settings will be merged with those generated by Hibernate Search, including analyzer definitions. When analysis is configured both through an analysis configurer and these custom settings, the behavior is undefined; it should not be relied upon.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__SCHEMA_MANAGEMENT_SETTINGS_FILE

Show more

string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".schema-management.mapping-file

Path to a file in the classpath holding a custom index mapping to be included in the index definition when creating an Elasticsearch index.

The file does not need to (and generally shouldn’t) contain the full mapping: Hibernate Search will automatically inject missing properties (index fields) in the given mapping.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__SCHEMA_MANAGEMENT_MAPPING_FILE

Show more

string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".analysis.configurer

One or more bean references to the component(s) used to configure full text analysis (e.g. analyzers, normalizers).

The referenced beans must implement ElasticsearchAnalysisConfigurer.

See Setting up the analyzers for more information.

Instead of setting this configuration property, you can simply annotate your custom ElasticsearchAnalysisConfigurer implementations with @SearchExtension and leave the configuration property unset: Hibernate Search will use the annotated implementation automatically. See this section for more information.

If this configuration property is set, it takes precedence over any @SearchExtension annotation.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__ANALYSIS_CONFIGURER

Show more

list of string

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".schema-management.required-status

The minimal Elasticsearch cluster status required on startup.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__SCHEMA_MANAGEMENT_REQUIRED_STATUS

Show more

green, yellow, red

yellow

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".schema-management.required-status-wait-timeout

How long we should wait for the status before failing the bootstrap.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__SCHEMA_MANAGEMENT_REQUIRED_STATUS_WAIT_TIMEOUT

Show more

Duration 

10S

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".indexing.queue-count

The number of indexing queues assigned to each index.

Higher values will lead to more connections being used in parallel, which may lead to higher indexing throughput, but incurs a risk of overloading Elasticsearch, i.e. of overflowing its HTTP request buffers and tripping circuit breakers, leading to Elasticsearch giving up on some request and resulting in indexing failures.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__INDEXING_QUEUE_COUNT

Show more

int

10

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".indexing.queue-size

The size of indexing queues.

Lower values may lead to lower memory usage, especially if there are many queues, but values that are too low will reduce the likeliness of reaching the max bulk size and increase the likeliness of application threads blocking because the queue is full, which may lead to lower indexing throughput.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__INDEXING_QUEUE_SIZE

Show more

int

1000

quarkus.hibernate-search-standalone.elasticsearch."backend-name".indexes."index-name".indexing.max-bulk-size

The maximum size of bulk requests created when processing indexing queues.

Higher values will lead to more documents being sent in each HTTP request sent to Elasticsearch, which may lead to higher indexing throughput, but incurs a risk of overloading Elasticsearch, i.e. of overflowing its HTTP request buffers and tripping circuit breakers, leading to Elasticsearch giving up on some request and resulting in indexing failures.

Note that raising this number above the queue size has no effect, as bulks cannot include more requests than are contained in the queue.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH_INDEXES__INDEX_NAME__INDEXING_MAX_BULK_SIZE

Show more

int

100

Management interface

Tipo

Por defecto

Root path for reindexing endpoints. This value will be resolved as a path relative to ${quarkus.management.root-path}.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_MANAGEMENT_ROOT_PATH

Show more

string

hibernate-search/standalone/

If management interface is turned on the reindexing endpoints will be published under the management interface. This property allows to enable this functionality by setting it to `true.

Environment variable: QUARKUS_HIBERNATE_SEARCH_STANDALONE_MANAGEMENT_ENABLED

Show more

boolean

false

About the Duration format

To write duration values, use the standard java.time.Duration format. See the Duration#parse() Java API documentation for more information.

You can also use a simplified format, starting with a number:

  • If the value is only a number, it represents time in seconds.

  • If the value is a number followed by ms, it represents time in milliseconds.

In other cases, the simplified format is translated to the java.time.Duration format for parsing:

  • If the value is a number followed by h, m, or s, it is prefixed with PT.

  • If the value is a number followed by d, it is prefixed with P.

About bean references

Referencing beans in configuration properties is optional and discouraged. Annotating beans with @SearchExtension achieves the same results. See this section for more information.

If you reference beans with a string value in configuration properties, the string is parsed in the following common formats:

  • bean: followed by the name of a @Named CDI bean. For example bean:myBean.

  • class: followed by the fully-qualified name of a class, to be instantiated through CDI if it is a CDI bean, or through its public, no-argument constructor otherwise. For example class:com.mycompany.MyClass.

  • An arbitrary string referencing a built-in implementation. Available values are detailed in the documentation of each configuration property, such as async/read-sync/write-sync/sync for quarkus.hibernate-search-standalone.indexing.plan.synchronization.strategy.

Other formats are also accepted, but are only useful for advanced use cases. See this section of Hibernate Search’s reference documentation for more information.