[id='indexing-annotations_{context}']
= {Brandname} native indexing annotations

When you enable indexing in caches, you configure {brandname} to create indexes.
You also need to provide {brandname} with a structured representation of the entities in your caches so it can actually index them.

[discrete]
== Overview of the {brandname} indexing annotations

@Indexed:: Indicates entities, or Protobuf message types, that {brandname} indexes.

To indicate the fields that {brandname} indexes use the indexing annotations.
You can use these annotations the same way for both embedded and remote queries.

@Basic:: Supports any type of field.
Use the `@Basic` annotation for numbers and short strings that don't require any transformation or processing.

@Decimal:: Use this annotation for fields that represent decimal values.

@Keyword:: Use this annotation for fields that are strings and intended for exact matching.
Keyword fields are not analyzed or tokenized during indexing.

@Text:: Use this annotation for fields that contain textual data and are intended for full-text search capabilities. You can use the analyzer to process the text and to generate individual tokens.

@Embedded:: Use this annotation to mark a field as an embedded object within the parent entity.
The `NESTED` structure preserves the original object relationship structure while the `FLATTENED` structure makes the leaf fields multivalued of the parent entity.
The default structure used by `@Embedded` is `NESTED`.

Each of the annotations supports a set of attributes that you can use to further describe how the entity is indexed.

.{brandname} annotations and supported attributes
[%autowidth,cols="1,1",stripes=even]
|===
|Annotation | Supported attributes

|@Basic
| Searchable, sortable, projectable, aggregable, indexNullAs

|@Decimal
| Searchable, sortable, projectable, aggregable, indexNullAs, decimalScale

|@Keyword
|Searchable, sortable, projectable, aggregable, indexNullAs, normalizer, norms

|@Text
|Searchable, projectable, norms, analyzer, searchAnalyzer, termVector

|===

[discrete]
== Using {brandname} annotations

You can provide {brandname} with indexing annotations in two ways:

* Annotate your Java classes or fields directly using the {brandname} annotations. +
You then generate or update your Protobuf schema, `.proto` files, before uploading them to {brandname} Server.

* Annotate Protobuf schema directly with `@Indexed` and `@Basic`, `@Keyword` or `@Text`. +
You then upload your Protobuf schema to {brandname} Server.
+
For example, the following schema uses the `@Text` annotation:
+
[source,java,options="nowrap",subs=attributes+]
----
include::protobuf/indexed_text.protobuf[]
----
