There are specialized ways to go about indexing fields, such as using a class bridge or the programmatic mapping API. Generally speaking, though, a property is indexed when it is annotated with
@Field. Therefore, one obvious way to avoid indexing a field is to simply not apply the annotation.
However, what if we want an entity class to be searchable in general, but we need to exclude certain instances of that class, based on the state of their data at runtime?
@Indexed annotation has an experimental second element,
, that gives us the ability to index conditionally. When this element is set, the normal indexing process will be intercepted by custom code, which can prevent an entity from being indexed based on ...