Loki
Loki

Reputation: 709

spring data mongo Language annotation

i'm trying to figure out how to use the @Language annotation from spring-data-rest-mongo project; I would like to store and retrive mongo document and do query on them; the simple document is as follow:

{ id: "abc", name: "light", "description": "wave or particle" }

I would like to store it and retrive it with different languages; any hint about it?

some sample using spring-data-rest would be greatly appreciated

thanks a lot

Upvotes: 0

Views: 823

Answers (2)

ciri-cuervo
ciri-cuervo

Reputation: 1756

To perform a search for a certain language I usually follow this approach: Multi-language documents example

The entity

@Document
@CompoundIndex(def = "{'language': 1, 'textProperty': 'text'}")

The repository

@Query("{'language': ?0, $text: {$search: ?1, $language: ?0}}")
Stream<TheDocuemnt> findTheDocument(String language, String criteria, Sort sort);

Upvotes: 0

Christoph Strobl
Christoph Strobl

Reputation: 6726

The @Language annotation is used to set the language_override property for a full text index and therefore does not help designing a collection of mulitlingual documents.
For more information please see the MongoDB Text Indexes and the Spring Data MongoDB Full Text Search support.

Upvotes: 1

Related Questions