Skip to content

Repository files navigation

Spring Data for Meilisearch

Maven Central Maintainability Rating Coverage License

The Spring Data Meilisearch project provides integration with the Meilisearch search engine.

Features

  • JavaConfig and XML namespace configuration for the Meilisearch client and repositories.

  • Entity mapping, document and search operations, index management, and index settings.

  • Blocking Spring Data repositories for CRUD, sorting, and paging.

Getting Started

Requires JDK 17 or newer and a reachable Meilisearch instance; individual APIs have server-version requirements (for example, sorted document listing needs Meilisearch 1.16 or later). The following example assumes the classes are in com.example.movies and the usual Spring Data Meilisearch imports are present:

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

interface MovieRepository extends MeilisearchRepository<Movie, String> {
}

@Configuration
@EnableMeilisearchRepositories(basePackages = "com.example.movies")
class Config extends MeilisearchConfiguration {

    @Override
    public ClientConfiguration clientConfiguration() {
        return ClientConfiguration.builder()
                .connectedToLocalhost()
                .withApiKey(System.getenv("MEILISEARCH_API_KEY"))
                .build();
    }
}

Inject MovieRepository into a Spring bean and call repository.save(movie). For an authenticated instance, use a scoped API key with the required permissions; do not embed the Meilisearch master key in application code. For an unauthenticated local instance, replace the example’s withApiKey(…​) argument with "" explicitly. See the getting-started guide for more setup and repository usage.

Maven configuration

Set spring-data-meilisearch.version in your POM to a published version from the Maven Central badge above, then add the dependency:

<dependency>
  <groupId>io.vanslog</groupId>
  <artifactId>spring-data-meilisearch</artifactId>
  <version>${spring-data-meilisearch.version}</version>
</dependency>

To use a development snapshot, set the dependency version property to the exact published -SNAPSHOT version and add the Central snapshots repository to your Maven <repositories>:

<repository>
  <id>central-snapshots</id>
  <url>https://central.sonatype.com/repository/maven-snapshots/</url>
</repository>

Guide

Reporting Issues

Spring Data uses GitHub as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:

  • Before you log a bug, please search the issue tracker to see if someone has already reported the problem.

  • If the issue doesn’t already exist, create a new issue.

  • Please provide as much information as possible with the issue report, we like to know the version of Spring Data Meilisearch that you are using and JVM version.

  • If you need to paste code, or include a stack trace format it as code using triple backtick.

  • If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.

Building from Source

Build with the bundled Maven Wrapper and JDK 17 or newer.

./mvnw clean install

If you use mvn instead, Maven 3.9.6 is the version pinned by this project’s wrapper.

Also see CONTRIBUTING.adoc if you wish to submit pull requests.

Building reference documentation

Build the authoring/PR preview documentation from the checked-out HEAD with Maven:

./mvnw -Pantora antora:antora

The generated documentation is available from target/site/index.html.

To build the published aggregate site locally, fetch main and release tags first, then generate the temporary publish playbook after Maven has prepared the Antora CLI dependencies:

git fetch --tags origin main
./mvnw -Pantora antora:antora
rm -rf target/site
node src/main/antora/generate-publish-playbook.mjs
npx --offline antora --to-dir target/site target/antora-publish-playbook.yml
node src/main/antora/copy-latest-stable-version.mjs

License

Spring Data Meilisearch is Open Source software released under the Apache 2.0 license.

About

Provide support to increase developer productivity in Java when using Meilisearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.

Topics

Resources

Contributing

Stars

25 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages