@Documented @Target(value={METHOD,FIELD}) @Retention(value=RUNTIME) public @interface IndexedEmbedded
This allows search queries on a single index to use data from multiple entities.
For example, let's consider this (incomplete) mapping:
{@literal @}Indexed
public class Book {
{@literal @}GenericField
private String title;
{@literal @}IndexedEmbedded
private List<Author> authors;
}
public class Author {
{@literal @}GenericField
private String firstName;
{@literal @}GenericField
private String lastName;
private List<Book> books;
}
The names of authors are stored in different objects,
thus by default they would not be included in documents created
for Book entities.
But we added the @IndexedEmbedded annotation to the authors property,
so Hibernate Search will embed this data in a authors field
of documents created for Book entities.
How exactly this embedding will happen depends on the configured storage type.
Let's consider this representation of the book "Levianthan Wakes":
With the default flattened storage type (more efficient),
the structure will be a little different from what one would expect:
To get the original structure, the nested storage type must be used,
but this has an impact on performance and how queries must be structured.
See the reference documentation for more information.
| Modifier and Type | Optional Element and Description |
|---|---|
ContainerExtraction |
extraction |
String[] |
includePaths
The paths of index fields from the indexed-embedded element that should be embedded.
|
int |
maxDepth
The max recursion depth for indexed-embedded processing.
|
String |
prefix |
ObjectFieldStorage |
storage |
public abstract String prefix
<property name>.,
meaning an object field with the same name as the property
will be defined in the parent document
to host the value of the child document.public abstract String[] includePaths
This takes precedence over maxDepth().
By default, if neither includePaths nor maxDepth() is defined,
all index fields are included.
prefix().public abstract int maxDepth
maxDepth is the number of `@IndexedEmbedded` that will be traversed
and for which all fields of the indexed-embedded element will be included,
even if these fields are not included explicitly through includePaths:
maxDepth=0 means fields of the indexed-embedded element are not included,
nor is any field of nested indexed-embedded elements,
unless these fields are included explicitly through includePaths().
maxDepth=1 means fields of the indexed-embedded element are included,
but not fields of nested indexed-embedded elements,
unless these fields are included explicitly through includePaths().
includePaths() attribute:
if includePaths() is empty, the default is Integer.MAX_VALUE (no limit)
if includePaths() is not empty, the default is 0
(only include fields included explicitly).public abstract ObjectFieldStorage storage
ObjectFieldStoragepublic abstract ContainerExtraction extraction
Map<TypeA, TypeB>:
defining the extraction as @ContainerExtraction(BuiltinContainerExtractors.MAP_KEY)
allows referencing map keys instead of map values.
By default, Hibernate Search will try to apply a set of extractors for common container types.ContainerExtractionCopyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.