Elasticsearch Annotations

Index

Use the Index annotation to specify which ElasticSearch index the class is associated with. The annotation has one single parameter (the name parameter), accepting the index name.

Id

Assign the ID annotation to a field that you want to use in the ElasticSearch index as a unique ID. The field value is represented in the id field within the index. If you don't provide an annotation for any field, the record's unique ID equals a generated UUID, automatically assigned by the ElasticSearch server to the record.

You can assign this annotation to multiple fields at the same time. The record's unique ID equals a concatenated text value of multiple Id fields.

Column

Use the column annotation to assign an ElasticSearch document attribute to a entity class field. You have to assign the annotation to a single field only. The annotation only has one parameter (the name parameter), where you have to specify the attribute name in the ElasticSearch document.

Analyzer

Use this annotation to set an analyzer for each attribute. If you don't specify this annotation, the ElasticSearch server uses its own default analyzer to analyze field values. The annotation has one parameter only (the type parameter), where you can specify the analyzer type. Available analyzer types are listed in the enum AnalyzerType.

Read more about analyzers in the ElasticSearch documentation .

DateFormat

If you want to store a date type value in the ElasticSearch index, then use the DateFormat annotation to set the format. If the annotation is left unspecified, the field value is stored using the server's default date format.