spring数据mongo语言注释

spring data mongo Language annotation

我正在尝试弄清楚如何使用 spring-data-rest-mongo 项目中的 @Language 注释; 我想存储和检索 mongo 文档并对它们进行查询;简单文档如下:

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

我想用不同的语言存储和检索它; 有什么提示吗?

一些使用 spring-data-rest 的示例将不胜感激

非常感谢

@Language注解用于为全文索引设置language_override属性,因此无助于设计多语言文档集合。
有关详细信息,请参阅 MongoDB Text Indexes and the Spring Data MongoDB Full Text Search support.

要搜索某种语言,我通常采用以下方法:Multi-language documents example

实体

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

存储库

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