Annotation Interface Searchable
This annotation provides metadata to guide how an object is serialized and stored in a search index, including
which collection it belongs to and how timestamps are derived. Annotating a class with @Searchable
enables
it to be stored and queried using DocumentStore
.
This annotation can also be used as a meta-annotation to define custom searchable types with preconfigured values.
Usage
@Searchable(collection = "projects", timestampPath = "createdAt")
public class Project {
@EntityId String id;
Instant createdAt;
String name;
}
Searchable value classes can be published using:
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe name of the collection where instances of this class should be indexed.A path expression used to extract an optional end timestamp from the object.boolean
Whether the annotated type should be included in search indexing.A path expression used to extract the primary timestamp from the object for indexing.
-
Element Details
-
searchable
boolean searchableWhether the annotated type should be included in search indexing.Set to
false
to explicitly opt out of indexing even if other settings are present.- Default:
true
-
collection
String collectionThe name of the collection where instances of this class should be indexed.If left blank, the collection name will default to the simple class name (e.g.,
Project
).- Default:
""
-
timestampPath
String timestampPathA path expression used to extract the primary timestamp from the object for indexing.This timestamp is used for sorting, querying ranges, and time-based document retrieval. The path can point to a property (e.g.,
"createdAt"
).If an
endPath
is not provided, the document will be stored with both the start and end equal to the timestamp extracted via this path. This is useful to represent point-in-time events (e.g., a complaint submission) versus open-ended reference data (e.g., a record that is active from a certain moment onward).- Default:
""
-
endPath
String endPathA path expression used to extract an optional end timestamp from the object.If set, this value is stored alongside the main timestamp to define a time window. This can be useful to model data that is valid between two moments in time. If left empty, the start timestamp is also used as the end.
- Default:
""
-