Appendix
This appendix contains reference material for Spring Data Meilisearch.
Schema
Spring Data Meilisearch uses www.vanslog.io/spring/data/meilisearch as its XML namespace URI and resolves the schema from the classpath through Spring’s META-INF/spring.schemas mechanism.
<meilisearch:meilisearch-client>
Creates a MeilisearchClient bean.
When omitted, the XML factory leaves the optional task-wait timeout attributes at 0, unlike the Java builder defaults of 5,000 ms and 50 ms. Set both attributes for applications that save documents or run other task-based operations.
| Attribute | Default | Description |
|---|---|---|
|
Bean id for the client instance. |
|
|
The Meilisearch server URL. |
|
|
No authentication |
Optional API key. Omit the attribute or set it to an empty string to send requests without authentication. Use a non-empty key for protected instances. |
|
Comma-delimited client-agent values sent in the |
|
|
|
Task-completion wait timeout in milliseconds. This is not an HTTP connection timeout. |
|
|
Polling interval in milliseconds while waiting for task completion. |
|
|
Reference to a bean implementing |
<meilisearch:repositories>
Enables Meilisearch repository scanning. It extends the generic Spring Data repository namespace and therefore also supports the standard repository namespace attributes.
| Attribute | Default | Description |
|---|---|---|
|
Package to scan for repository interfaces. |
|
|
|
Reference to the |
Example
The example uses MeilisearchTemplate’s one-argument constructor, which creates the default mapping converter and Jackson `ObjectMapper. Wire the converter and mapper explicitly if you need custom conversions.
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:meilisearch="http://www.vanslog.io/spring/data/meilisearch"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.vanslog.io/spring/data/meilisearch
http://www.vanslog.io/spring/data/meilisearch/spring-meilisearch-1.0.xsd">
<context:property-placeholder/>
<bean id="jsonHandler" class="com.meilisearch.sdk.json.GsonJsonHandler"/>
<meilisearch:meilisearch-client
id="meilisearchClient"
host-url="http://localhost:7700"
api-key="${MEILISEARCH_API_KEY}"
request-timeout="5000"
request-interval="50"
json-handler-ref="jsonHandler"/>
<bean id="meilisearchTemplate"
class="io.vanslog.spring.data.meilisearch.client.msc.MeilisearchTemplate">
<constructor-arg ref="meilisearchClient"/>
</bean>
<meilisearch:repositories
base-package="com.example.movies"
meilisearch-template-ref="meilisearchTemplate"/>
</beans>