O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hibernate Search by Example

Book Description

Explore the Hibernate Search system and use its extraordinary search features in your own applications

  • Add search capability to your custom applications
  • Integrate with the core Hibernate system, using traditional APIs or JPA
  • Write search queries in no time that may be simple or complex

In Detail

Users expect software to be highly intelligent when searching data. Searches should span across multiple data points at once, and be able to spot patterns and groupings in the results found. Searches should be able to fix user typos, and use terms related to the user’s search words. Searching is at its best when it pleasantly surprises us, seeming to understand the real gist of what we’re looking for better than we understood it ourselves! Where can we find such a search system and how can we use it efficiently?

Hibernate Search by Example is a practical, step-by-step tutorial, which guides you from the basics of Hibernate Search to its advanced features. The book builds toward a complete sample application, slowly fleshed out to demonstrate each and every concept being introduced in each chapter. By the end you will have a solid foundation for using Hibernate Search in real production applications.

This book starts with a simple example, and incrementally builds upon it to showcase each Hibernate Search feature introduced. By the end of the book you will have a working, functionality-rich application, and a deeper understanding than you might have had from looking at code snippets in a vacuum.

You will learn how to integrate search into core Hibernate applications, whether they are XML or annotation-based, or if you are using JPA. You will see how to fine-tune the relevance of search results, and design searches that can account for user typos or automatically reach for related terms. We will take advantage of performance optimization strategies, from running Hibernate Search in a cluster to reducing the need for database access at all.

Hibernate Search by Example provides everything you need to know to incorporate search functionality into your own custom applications.

Table of Contents

  1. Hibernate Search by Example
    1. Table of Contents
    2. Hibernate Search by Example
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What is Hibernate Search?
      2. What this book covers
      3. What you need for this book
      4. Who this book is for
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Your First Application
      1. Creating an entity class
      2. Preparing the entity for Hibernate Search
      3. Loading the test data
      4. Writing the search query code
      5. Selecting a build system
      6. Setting up the project and importing Hibernate Search
      7. Running the application
      8. Summary
    9. 2. Mapping Entity Classes
      1. Choosing an API for Hibernate ORM
      2. Field mapping options
        1. Multiple mappings for the same field
        2. Mapping numeric fields
      3. Relationships between entities
        1. Associated entities
          1. Querying associated entities
        2. Embedded objects
      4. Partial indexing
      5. The programmatic mapping API
      6. Summary
    10. 3. Performing Queries
      1. Mapping API versus query API
      2. Using JPA for queries
      3. Setting up a project for Hibernate Search and JPA
      4. The Hibernate Search DSL
        1. Keyword query
          1. Fuzzy search
          2. Wildcard search
        2. Exact phrase query
        3. Range query
        4. Boolean (combination) queries
      5. Sorting
      6. Pagination
      7. Summary
    11. 4. Advanced Mapping
      1. Bridges
        1. One-to-one custom conversion
          1. Mapping date fields
          2. Handling null values
          3. Custom string conversion
            1. StringBridge
            2. TwoWayStringBridge
            3. ParameterizedBridge
        2. More complex mappings with FieldBridge
          1. Splitting a single variable into multiple fields
          2. Combining multiple properties into a single field
          3. TwoWayFieldBridge
      2. Analysis
        1. Character filtering
        2. Tokenization
        3. Token filtering
        4. Defining and selecting analyzers
          1. Static analyzer selection
          2. Dynamic analyzer selection
      3. Boosting search result relevance
        1. Static boosting at index-time
        2. Dynamic boosting at index-time
      4. Conditional indexing
      5. Summary
    12. 5. Advanced Querying
      1. Filtering
        1. Creating a filter factory
          1. Adding a filter key
        2. Establishing a filter definition
        3. Enabling the filter for a query
      2. Projection
        1. Making a query projection-based
        2. Converting projection results to an object form
        3. Making Lucene fields available for projection
      3. Faceted search
        1. Discrete facets
        2. Range facets
      4. Query-time boosting
      5. Placing time limits on a query
      6. Summary
    13. 6. System Configuration and Index Management
      1. Automatic versus manual indexing
        1. Individual updates
          1. Adds and updates
          2. Deletes
        2. Mass updates
      2. Defragmenting an index
        1. Manual optimization
        2. Automatic optimization
          1. Custom optimizer strategy
      3. Choosing an index manager
      4. Configuring workers
        1. Execution mode
        2. Thread pool
        3. Buffer queue
      5. Selecting and configuring a directory provider
        1. Filesystem-based
          1. Locking strategy
        2. RAM-based
      6. Using the Luke utility
      7. Summary
    14. 7. Advanced Performance Strategies
      1. General tips
      2. Running applications in a cluster
        1. Simple clusters
        2. Master-slave clusters
          1. Directory providers
          2. Worker backends
          3. A working example
      3. Sharding Lucene indexes
      4. Summary
    15. Index