Chapter 4. Mapping more advanced data structures

 

This chapter covers

  • Custom bridges
  • Mapping relationships

Although Hibernate Search comes with built-in bridges for most useful Java types, they won’t cover all your needs. It’s not uncommon in an application to need to define specific types. Even if the type you’re wanting to index is supported, its string representation generated by Hibernate Search and indexed by Lucene might not be appropriate for the kind of full-text query you’re looking for. Generally speaking, what happens when you need to map the unexpected? Hibernate Search has the notion of a bridge, which converts the object structure into the Lucene structure. You can extend the supporting types and their behavior by writing your own custom bridge implementation. The first part of this chapter covers this functionality.

Note

If you’re still uncomfortable with the notion of mapping, read chapter 3 again or jump to chapter 5. You can easily come back to this chapter later in your journey. Thanks to chapter 3, you know how to map most of the domain model. For 80 percent of your mapping and even for many applications, this is all you’ll need to know. We’ll cover more advanced needs in this chapter; the extra 20 percent of mappings require either additional features or more flexibility.

4.1. Mapping the unexpected: custom bridges

4.2. Mapping relationships between entities

4.3. Summary