For the latest stable version, please use Spring Data Meilisearch 0.12.0!

Repository Methods and Limitations

Spring Data Meilisearch implements the standard repository base methods and keeps custom search composition in MeilisearchOperations. The supported repository contract is intentionally narrower than query-enabled Spring Data stores.

Choosing Between Repositories and Operations

Use MeilisearchRepository for the built-in CRUD, ID lookup, collection listing, sorting, and pageable methods. Use MeilisearchOperations for search features that need an explicit Meilisearch query or richer search result data, such as facets, similar-document search, or federated multi-search.

For a mapped domain type such as Movie, inject MeilisearchOperations when you need to compose a search query directly:

import io.vanslog.spring.data.meilisearch.core.MeilisearchOperations;
import io.vanslog.spring.data.meilisearch.core.SearchHits;
import io.vanslog.spring.data.meilisearch.core.query.BasicQuery;

class MovieSearchService {

  private final MeilisearchOperations operations;

  MovieSearchService(MeilisearchOperations operations) {
    this.operations = operations;
  }

  SearchHits<Movie> search(String text) {
    BasicQuery query = BasicQuery.builder().withQ(text).build();
    return operations.search(query, Movie.class);
  }
}

This service-level call returns Meilisearch search hits. A repository method such as findByTitle(…​) is not an equivalent shortcut.

Unsupported Repository Query Methods

The repository factory does not implement query-method resolution. Built-in methods such as findById(…​) are supported because they are part of the repository base contract, but methods that require query resolution are rejected during repository bootstrap. This includes:

  • derived finder, count, and delete methods such as findByTitle(…​) or countByTitle(…​),

  • methods annotated with repository @Query,

  • named-query-backed repository methods.

For example, declaring the following method on a repository causes bootstrap to fail with an IllegalStateException whose message begins Meilisearch repository query methods are not supported yet:

import io.vanslog.spring.data.meilisearch.annotations.Document;
import io.vanslog.spring.data.meilisearch.repository.MeilisearchRepository;
import org.springframework.data.annotation.Id;

@Document(indexUid = "movies", applySettings = false)
class Movie {
  @Id String id;
  String title;
}

interface MovieRepository extends MeilisearchRepository<Movie, String> {

  Movie findByTitle(String title);
}

Changing queryLookupStrategy or namedQueriesLocation does not add query-method support. Those attributes remain available for Spring Data configuration compatibility; see Repository Configuration.

Paging, Sorting, and Result Limits

  • A paged findAll(Pageable) is search-backed. Its Page total comes from the total reported by Meilisearch search results. pagination.maxTotalHits can cap returned content without capping that reported total.

  • An unpaged findAll(Pageable) uses the document-list API, retrieves all documents into memory, and sets the Page total to the retrieved count. It is not limited by maxTotalHits.

  • findAll() also lists all documents through the document API. Sorted findAll(Sort) and sorted unpaged findAll(Pageable) count first, then fetch up to that count; additions between those requests may be absent.

  • Sorting document listings requires a sortable index attribute and Meilisearch 1.16 or later. findAllById(…​) uses native ID-list retrieval, available from Meilisearch 1.14, with no fallback on older servers.

  • Document-list reads are not capped by search maxTotalHits and ignore displayedAttributes.

  • Empty saveAll(…​), deleteAll(Iterable), and deleteAllById(…​) operations complete without a server request. The no-argument deleteAll() still deletes all documents for the entity type.

For full method-to-API behavior, see Method Behavior at a Glance. For query composition and search result metadata, use MeilisearchOperations directly.