|
This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Data Meilisearch 0.8.1! |
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.
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.
@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.
// 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.