Interface DocumentOperations
- All Known Subinterfaces:
MeilisearchOperations
- All Known Implementing Classes:
MeilisearchTemplate
public interface DocumentOperations
The operations for the Documents API.
- Author:
- Junghoon Ban
-
Method Summary
Modifier and TypeMethodDescriptionlongCounts documents of the given type that match the supplied Meilisearch filter.booleanDeletes all entities of the given type with the given document ids.booleanDeletes the entity with the given document id.<T> booleanDeletes the given entities.<T> booleandelete(T entity) Deletes a given entity.booleanDeletes all entities of the given type.longdeleteByFilter(Class<?> clazz, String filter) Deletes documents of the given type that match the supplied Meilisearch filter and waits for the deletion task to complete.booleanChecks whether an entity with the given document id exists.<T> List<T>Retrieves all entities of the given type through the documents/fetch endpoint in one request.<T> List<T>Retrieves entities of the given type in the given order.<T> TRetrieves an entity by its document id.<T> List<T>Retrieves all entities of the given type with the given document ids.<T> List<T>Saves all given entities.<T> Tsave(T entity) Saves an entity.
-
Method Details
-
save
<T> T save(T entity) Saves an entity.- Type Parameters:
T- the type of the entity- Parameters:
entity- the entity to save- Returns:
- the saved entity
-
save
Saves all given entities. An empty list is returned without a server request.- Type Parameters:
T- the type of the entity- Parameters:
entities- the entities to save- Returns:
- the saved entities as list
-
get
Retrieves an entity by its document id.- Type Parameters:
T- the type of the entity- Parameters:
documentId- the document id of the entityclazz- the entity class, must be annotated withDocument- Returns:
- the entity with the given document id or null if none found
-
multiGet
Retrieves all entities of the given type with the given document ids. Native ID-list retrieval requires Meilisearch 1.14 or later. Results preserve the requested id order, including duplicate ids; missing documents are omitted. The ids are fetched in internal batches.- Type Parameters:
T- the type of the entity- Parameters:
documentIds- the document ids of the entitiesclazz- the entity class, must be annotated withDocument- Returns:
- all entities with the given document ids
-
findAll
Retrieves all entities of the given type through the documents/fetch endpoint in one request. The entire result is held in memory. Document retrieval ignoresdisplayedAttributes.- Type Parameters:
T- the type of the entity- Parameters:
clazz- the entity class, must be annotated withDocument- Returns:
- all entities of the given type
-
findAll
Retrieves entities of the given type in the given order. Sorted listing first counts the documents, then fetches up to that count in one request; concurrent additions can leave the returned result short of the current total. The entire result is held in memory. Both listing overloads use the documents/fetch endpoint without selecting fields. Sorting requires Meilisearch 1.16 or later.- Type Parameters:
T- the type of the entity- Parameters:
clazz- the entity class, must be annotated withDocumentsort- the sort order, whose properties must be sortable in the index- Returns:
- entities in sorted order, up to the count obtained before fetching
-
exists
Checks whether an entity with the given document id exists.- Parameters:
documentId- the document id of the entityclazz- the entity class, must be annotated withDocument- Returns:
- true if an entity with the given document id exists
-
count
Counts documents of the given type that match the supplied Meilisearch filter.- Parameters:
clazz- the entity class, must be annotated withDocumentfilter- the non-empty Meilisearch filter expression- Returns:
- the number of matching documents
-
delete
Deletes the entity with the given document id.- Parameters:
documentId- the document id of the entityclazz- the entity class, must be annotated withDocument- Returns:
- true if an entity was deleted
-
delete
<T> boolean delete(T entity) Deletes a given entity.- Type Parameters:
T- the type of the entity- Parameters:
entity- the entity to delete- Returns:
- true if an entity was deleted
-
delete
Deletes all entities of the given type with the given document ids. An empty list succeeds without a server request.- Parameters:
clazz- the entity class, must be annotated withDocumentdocumentIds- the document ids of the entities- Returns:
- true if all entities were deleted
-
delete
Deletes the given entities. An empty list succeeds without a server request.- Type Parameters:
T- the type of the entity- Parameters:
entities- the entities to delete- Returns:
- true if all entities were deleted
-
deleteAll
Deletes all entities of the given type.- Parameters:
clazz- the entity class, must be annotated withDocument- Returns:
- true if all entities were deleted
-
deleteByFilter
Deletes documents of the given type that match the supplied Meilisearch filter and waits for the deletion task to complete.- Parameters:
clazz- the entity class, must be annotated withDocumentfilter- the non-empty Meilisearch filter expression- Returns:
- the number of documents actually deleted
-