Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
hibernate-search-7.1.2.Final-dist.zip | 2024-08-30 | 65.5 MB | |
hibernate-search-7.1.2.Final-dist.tar.gz | 2024-08-30 | 54.9 MB | |
changelog.txt | 2024-08-30 | 308.4 kB | |
README.md | 2024-08-30 | 6.1 kB | |
Totals: 4 Items | 120.6 MB | 1 |
Hibernate Search
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:
- Declarative mapping of entity properties to index fields, either through annotations or a programmatic API.
- On-demand mass indexing of all entities in the database, to initialize the indexes with pre-existing data.
- On-the-fly listener-triggered indexing of entities modified through a Hibernate ORM session, to always keep the indexes up-to-date.
- A Search DSL to easily build full-text search queries and retrieve the hits as Hibernate ORM entities.
- And more: configuration of analyzers, many different predicates and sorts in the Search DSL, spatial support. search queries returning projections instead of entities, aggregations, advanced customization of the mapping using bridges, ...
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:
- Available versions and compatibility matrix
- Reference documentation for all versions (current and past)
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.