我在Spring Data / MongoDB应用程序中有以下文档
@Document
public class DocumentFile {
@Id
private String id;
@TextIndexed
private List<DocumentFileVersion> documentFileVersions;
...
}
有人提到DocumentFileVersion
。这个类看起来像这样:
public class DocumentFileVersion {
private String filePath; // contains project name
...
}
DocumentFile
包含在项目中。
我现在的问题是,如果我搜索项目名称,也会找到DocumentFile
,因为它们的项目名称包含在字段DocumentFile#DocumentFileVersions#filePath
我现在的问题是,是否有可能从filePath
中排除@TextIndexed
字段?
答案 0 :(得分:1)
如果DocumentFileVersion
在您的控制范围之内,那么您可以将@TextIndexed
仅添加到DocumentFileVersion
中您希望编入索引的那些属性,只留下filePath
。< / p>
另一种方法是通过IndexOperations
手动设置索引。也许你想看一下examples project。