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 Type
    Method
    Description
    long
    count(Class<?> clazz, String filter)
    Counts documents of the given type that match the supplied Meilisearch filter.
    boolean
    delete(Class<?> clazz, List<String> documentIds)
    Deletes all entities of the given type with the given document ids.
    boolean
    delete(String documentId, Class<?> clazz)
    Deletes the entity with the given document id.
    <T> boolean
    delete(List<T> entities)
    Deletes the given entities.
    <T> boolean
    delete(T entity)
    Deletes a given entity.
    boolean
    deleteAll(Class<?> clazz)
    Deletes all entities of the given type.
    long
    deleteByFilter(Class<?> clazz, String filter)
    Deletes documents of the given type that match the supplied Meilisearch filter and waits for the deletion task to complete.
    boolean
    exists(String documentId, Class<?> clazz)
    Checks whether an entity with the given document id exists.
    <T> List<T>
    findAll(Class<T> clazz)
    Retrieves all entities of the given type through the documents/fetch endpoint in one request.
    <T> List<T>
    findAll(Class<T> clazz, Sort sort)
    Retrieves entities of the given type in the given order.
    <T> T
    get(String documentId, Class<T> clazz)
    Retrieves an entity by its document id.
    <T> List<T>
    multiGet(Class<T> clazz, List<String> documentIds)
    Retrieves all entities of the given type with the given document ids.
    <T> List<T>
    save(List<T> entities)
    Saves all given entities.
    <T> T
    save(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

      <T> List<T> save(List<T> entities)
      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

      @Nullable <T> T get(String documentId, Class<T> clazz)
      Retrieves an entity by its document id.
      Type Parameters:
      T - the type of the entity
      Parameters:
      documentId - the document id of the entity
      clazz - the entity class, must be annotated with Document
      Returns:
      the entity with the given document id or null if none found
    • multiGet

      <T> List<T> multiGet(Class<T> clazz, List<String> documentIds)
      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 entities
      clazz - the entity class, must be annotated with Document
      Returns:
      all entities with the given document ids
    • findAll

      <T> List<T> findAll(Class<T> clazz)
      Retrieves all entities of the given type through the documents/fetch endpoint in one request. The entire result is held in memory. Document retrieval ignores displayedAttributes.
      Type Parameters:
      T - the type of the entity
      Parameters:
      clazz - the entity class, must be annotated with Document
      Returns:
      all entities of the given type
    • findAll

      <T> List<T> findAll(Class<T> clazz, Sort sort)
      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 with Document
      sort - the sort order, whose properties must be sortable in the index
      Returns:
      entities in sorted order, up to the count obtained before fetching
    • exists

      boolean exists(String documentId, Class<?> clazz)
      Checks whether an entity with the given document id exists.
      Parameters:
      documentId - the document id of the entity
      clazz - the entity class, must be annotated with Document
      Returns:
      true if an entity with the given document id exists
    • count

      long count(Class<?> clazz, String filter)
      Counts documents of the given type that match the supplied Meilisearch filter.
      Parameters:
      clazz - the entity class, must be annotated with Document
      filter - the non-empty Meilisearch filter expression
      Returns:
      the number of matching documents
    • delete

      boolean delete(String documentId, Class<?> clazz)
      Deletes the entity with the given document id.
      Parameters:
      documentId - the document id of the entity
      clazz - the entity class, must be annotated with Document
      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

      boolean delete(Class<?> clazz, List<String> documentIds)
      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 with Document
      documentIds - the document ids of the entities
      Returns:
      true if all entities were deleted
    • delete

      <T> boolean delete(List<T> entities)
      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

      boolean deleteAll(Class<?> clazz)
      Deletes all entities of the given type.
      Parameters:
      clazz - the entity class, must be annotated with Document
      Returns:
      true if all entities were deleted
    • deleteByFilter

      long deleteByFilter(Class<?> clazz, String filter)
      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 with Document
      filter - the non-empty Meilisearch filter expression
      Returns:
      the number of documents actually deleted