Meilisearch Document
Spring Data Meilisearch provides a simple way to define a Document.
Document definition
To define the Document, you need to annotate a class with the @Document annotation.
As an example, the following class defines a Movie document with id, title, description and genres fields.
Example 1. The sample document
import io.vanslog.spring.data.meilisearch.annotations.Document;
import org.springframework.data.annotation.Id;
@Document(indexUid = "movies")
public class Movie {
@Id private int id;
private String title;
private String description;
private String[] genres;
}
Index UID
The Index UID is a unique identifier for an index.
It can be defined explicitly with the indexUid attribute in the @Document annotation.
Example 2. Explicit Index UID
@Document(indexUid = "movies")
public class Movie {
// fields
}
If the indexUid is not specified or the class is not annotated with @Document, the class name will be used as the index UID by default.
Example 3. Default Index UID (using class name)
// No @Document annotation or no indexUid specified
public class Movie {
// fields
}
In this case, Movie is used as the index UID.
Document id
The Document id is a unique identifier for a document in an index.
It can be defined with @Id annotation or id field.