Annotation Type Searchable


@Retention(CLASS) @Target(TYPE) public @interface Searchable

Keeps a full-text search index in step with an entity on the server.

After a transaction commits, every entity of this type it persisted or updated is written to the index, and every one it removed is deleted from it, through the server's search engine (cn1.search.url: Elasticsearch, OpenSearch, or the application's own database). A transaction that rolls back changes nothing in the index.

The search document holds the entity's persistent fields, keyed by column name. When any field is marked SearchField only those fields are indexed, which keeps a password hash or a token out of a search cluster.

@Entity @Searchable(index = "products")
public class Product {
    @Id public long id;
    @SearchField public String name;
    @SearchField public String description;
    String supplierCode;
}

A bulk update or delete statement changes rows, not entities, and is not reflected in the index. On a device this annotation has no effect.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The index name: lowercase letters, digits, - and _, not starting with - or _.
  • Element Details

    • index

      String index
      The index name: lowercase letters, digits, - and _, not starting with - or _. Empty means the entity's table name.
      Default:
      ""