java - Spring Data MongoDB Overriding text index language in a compound index for inner fields -
here's document class:
@document(language = "russian") @compoundindexes({ @compoundindex(def = "{'tempid' : 1, 'persons.title' : 'text', 'otherpersons.title' : 'text'}", background = true)}) public class companyhistory implements persistable<string> { @id private string id; private string tempid; private list<person> persons; private list<otherperson> otherpersons; ... }
person
, otherperson
contains 2 strings, getteres, setters.
question: how override language on text index (defaults english) inner fields when building compound index? looks setting language
works @textindexed
annotation.
had similar problem (text index subentities) , tried find way set language_override
, default_language
via @compoundindex
, nothing worked me.
finally ended following solution:
textindexdefinition textindex = new textindexdefinition.textindexdefinitionbuilder() .withdefaultlanguage("none").withlanguageoverride("dummy") .named("text_user_search") .onfield("user.name") .onfield("user.mail") .build(); mongotemplate.indexops(user.class).ensureindex(textindex);
Comments
Post a Comment