Skip to content

wklaczynski/hibernate-search

This branch is 530 commits behind hibernate/hibernate-search:main.

Folders and files

NameName
Last commit message
Last commit date
Mar 6, 2024
Mar 25, 2024
Mar 22, 2024
Mar 27, 2024
Feb 12, 2024
Mar 27, 2024
Mar 26, 2024
Feb 12, 2024
Mar 20, 2024
Mar 20, 2024
Mar 27, 2024
Mar 21, 2024
Mar 20, 2024
Mar 21, 2024
Jul 5, 2023
Sep 19, 2023
Mar 6, 2024
Aug 17, 2023
Mar 15, 2024
Mar 27, 2024
Dec 4, 2023
Mar 6, 2024
Feb 12, 2024
Aug 10, 2023
Aug 10, 2017
Feb 14, 2018
Jun 1, 2023
Jun 1, 2023
Mar 27, 2024

Repository files navigation

Hibernate Search

Maven Central Build Status Sonar Coverage Quality gate Develocity

Description

Hibernate Search automatically extracts data from Hibernate ORM entities to push it to local Apache Lucene indexes or remote Elasticsearch/OpenSearch indexes.

It features:

For example, map your entities like this:

@Entity
// This entity is mapped to an index
@Indexed
public class Book {

    // The entity ID is the document ID
    @Id
    @GeneratedValue
    private Integer id;

    // This property is mapped to a document field
    @FullTextField
    private String title;

    @ManyToMany
    // Authors will be embedded in Book documents
    @IndexedEmbedded
    private Set<Author> authors = new HashSet<>();

    // Getters and setters
    // ...
}

@Entity
public class Author {

    @Id
    @GeneratedValue
    private Integer id;

    // This property is mapped to a document field
    @FullTextField
    private String name;

    @ManyToMany(mappedBy = "authors")
    private Set<Book> books = new HashSet<>();

    // Getters and setters
    // ...
}

Index existing data like this:

SearchSession searchSession = Search.session( entityManager );
MassIndexer indexer = searchSession.massIndexer( Book.class );
indexer.startAndWait();

Listener-triggered indexing does not require any change to code based on JPA or Hibernate ORM:

Author author = new Author();
author.setName( "Isaac Asimov" );

Book book = new Book();
book.setTitle( "The Caves Of Steel" );
book.getAuthors().add( author );
author.getBooks().add( book );

entityManager.persist( author );
entityManager.persist( book );

And search like this:

SearchResult<Book> result = Search.session( entityManager )
        .search( Book.class )
        .where( f -> f.match()
                .fields( "title", "authors.name" )
                .matching( "Isaac" ) )
        .fetch( 20 );

List<Book> hits = result.hits();
long totalHitCount = result.total().hitCount();

License

This software and its documentation are distributed under the terms of the GNU Lesser General Public License (LGPL), version 2.1 or later.

See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.

Getting started

Getting started guides are available here.

Fore more information, refer to the Hibernate Search website:

For offline use, distribution bundles downloaded from SourceForge also include the reference documentation for the downloaded version in PDF and HTML format.

Contact

Latest Documentation

See http://hibernate.org/search/documentation/.

Bug Reports

See the HSEARCH project on the Hibernate JIRA instance: https://hibernate.atlassian.net/browse/HSEARCH.

Community Support

See http://hibernate.org/community/.

Contributing

New contributors are always welcome.

See CONTRIBUTING.md to get started.

The contribution guide also includes build instructions.

About

Hibernate Search: full-text search for domain model

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%