Movatterモバイル変換


[0]ホーム

URL:


ORM
AboutReleasesDocumentationQuicklyMigration guidesBooksProcessorToolingEnversContributePaid support
Source codeIssue trackerSecurity issueForumCIRoadmap
Search
AboutReleasesDocumentationMigration guidesMore resourcesRoadmapContributeToolingPaid supportFAQ
Source codeIssue trackerSecurity issueForumWikiCI
Validator
AboutReleasesDocumentationMigration guidesRoadmapContributeToolingPaid supportFAQ
Source codeIssue trackerSecurity issueForumCI
Reactive
AboutReleasesDocumentationContributePaid support
Source codeIssue trackerSecurity issueForumCI
Repositories
AboutReleasesDocumentationQuickly
Source codeIssue trackerSecurity issue
Others
Community
CommunityGovernanceCommonhaus - MembershipCommonhaus - Joining FAQContribute - GuidelinesContribute - Set up IntelliJ IDEAContribute - Set up Eclipse IDEContribute - Build Hibernate ORMTeamContributors to ORMContributors to SearchContributors to ValidatorContributors to ReactiveContributors to ToolsContributors to OGMCorporate contributorsCompatibility policyMaintenance policyLicensesKeys
BlogForumsFollow us
HibernateMenu
Hibernate
ORMSearchValidatorReactiveRepositoriesOthers
BlogForumsCommunityFollow us

Hibernate Search

ORM. Lucene. Elasticsearch. Integrated.

Automatic indexing of Hibernate ORM entities into Apache Lucene or Elasticsearch.Advanced search API: full-text, geospatial, aggregations and more.

AboutDocumentationMigration guidesMore resourcesRoadmapContributeToolingPaid supportFAQ
Source codeIssue trackerSecurity issueForumWikiCI

Released under theASL v2since version7.2.0.Alpha2(check release descriptions for earlier versions)

Full-text search for entities

Hibernate Search automatically extracts data from Hibernate ORM entities to push it tolocalApache Lucene indexesor remoteElasticsearch/OpenSearch indexes.

It features:

  • Declarative mappingof entity properties to index fields,either through annotations or a programmatic API.

  • On-demand mass indexingof all entities in the database,to initialize the indexes with pre-existing data.

  • On-the-fly listener-triggered indexingof entities modified through a Hibernate ORM session,to always keep the indexes up-to-date.

  • A Search DSLto easily build full-text search queriesand retrieve the hits as Hibernate ORM entities.

  • And much more! (see below)

For example, map your entities like this:

@Entity
// This entity is mapped to an index
@Indexed
publicclassBook {

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

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

@ManyToMany
// Authors will be embedded in Book documents
@IndexedEmbedded
privateSet<Author> authors =newHashSet<>();

// Getters and setters
// ...
}

@Entity
publicclassAuthor {

@Id
@GeneratedValue
privateInteger id;

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

@ManyToMany(mappedBy ="authors")
privateSet<Book> books =newHashSet<>();

// Getters and setters
// ...
}

Index pre-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 =newBook();
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();

Full control

Unlike with web search, this is your data, your domain, your application, stored wherever you decide.

You can choose what to index (and how to index it) very precisely withper-property mappingand go even further withcustom bridges.

You also have far better control on how your data is processed withconfigurable analysis,so you can:

  • Tune text processing for specific languages.

  • Tune text processing for domain specific terminology (e.g. medical terms, custom acronyms expansion, …​).

  • Control the ranking process: which results are more important.

Easy yet powerful

Designed to be easy to use from the ground up.Handles schema initialization, indexing and query syntax transparently while you focus on the business side of your search.

The Search DSL exposes many differentpredicatesandsortsthrough a succinct, easy-to-use API.

And if you need to go beyond, it won’t stop you:nativeLucene QueriesorElasticsearch JSONcan be inserted right in the middle of Search DSL queries.

Local or distributed

While you’ll find that performance of a "single box" based onApache Lucene is exceptional,you can also scale out by distributing your applicationand relying on anElasticsearch cluster for indexing,with only a few configuration changes.

For even better scaling and coordination with the Elasticsearch backend,Hibernate Search can also send entity change events toa transactional outbox table in the database,spreading indexing across multiple asynchronous event processors.

Spatial queries

Indexing geo-localized entities is as easy asadding the@GenericField annotation.

Filter results around a certain locationlike the user position,and use adistance sortto pull to the top the matching pizzerias which are closest to the user.

Aggregations

Get search resultsaggregated by groups and categories.

For example webshops will want to show all hits,but also display a count of hits by price range and brand.

Latest news

Other news

Projects

Follow us

Contribute and community

Back to top

[8]ページ先頭

©2009-2025 Movatter.jp