项目作者: hibernate

项目描述 :
Hibernate Search: full-text search for domain model
高级语言: Java
项目地址: git://github.com/hibernate/hibernate-search.git
创建时间: 2010-10-15T15:55:09Z
项目社区:https://github.com/hibernate/hibernate-search

开源协议:Other

下载


Hibernate Search

Maven Central
Build Status
Sonar Coverage
Quality gate
Develocity
Reproducible Builds

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:

  1. @Entity
  2. // This entity is mapped to an index
  3. @Indexed
  4. public class Book {
  5. // The entity ID is the document ID
  6. @Id
  7. @GeneratedValue
  8. private Integer id;
  9. // This property is mapped to a document field
  10. @FullTextField
  11. private String title;
  12. @ManyToMany
  13. // Authors will be embedded in Book documents
  14. @IndexedEmbedded
  15. private Set<Author> authors = new HashSet<>();
  16. // Getters and setters
  17. // ...
  18. }
  19. @Entity
  20. public class Author {
  21. @Id
  22. @GeneratedValue
  23. private Integer id;
  24. // This property is mapped to a document field
  25. @FullTextField
  26. private String name;
  27. @ManyToMany(mappedBy = "authors")
  28. private Set<Book> books = new HashSet<>();
  29. // Getters and setters
  30. // ...
  31. }

Index existing data like this:

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

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

  1. Author author = new Author();
  2. author.setName( "Isaac Asimov" );
  3. Book book = new Book();
  4. book.setTitle( "The Caves Of Steel" );
  5. book.getAuthors().add( author );
  6. author.getBooks().add( book );
  7. entityManager.persist( author );
  8. entityManager.persist( book );

And search like this:

  1. SearchResult<Book> result = Search.session( entityManager )
  2. .search( Book.class )
  3. .where( f -> f.match()
  4. .fields( "title", "authors.name" )
  5. .matching( "Isaac" ) )
  6. .fetch( 20 );
  7. List<Book> hits = result.hits();
  8. long totalHitCount = result.total().hitCount();

License

This software and its documentation are distributed under the terms of
the Apache License version 2.0 (Apache-2.0).

The Apache-2.0 license text is included verbatim in the LICENSE.txt file
in the root directory of the repository.

Note that Hibernate Search 7.2.0.Alpha1 and lower are distributed under a different license;
for more information, check the licensing information provided alongside published binaries,
or the corresponding branch in the source repository.

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 https://hibernate.org/search/documentation.

Bug Reports

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

Community Support

See https://hibernate.org/community.

Contributing

New contributors are always welcome.

See CONTRIBUTING.md to get started.

The contribution guide also includes build instructions.