Spring 数据 - @TextIndexed - 排除 属性

Spring data - @TextIndexed - exclude property

我的 Spring Data/MongoDB 申请中有以下文件

@Document
public class DocumentFile {

    @Id
    private String id;
    @TextIndexed
    private List<DocumentFileVersion> documentFileVersions;

    ...
}

有做参考DocumentFileVersion。这个 class 看起来像这样:

public class DocumentFileVersion {

    private String filePath; // contains project name
    ...
}

DocumentFile 包含在一个项目中。 我现在的问题是,如果我搜索项目名称,也会找到 DocumentFile,因为它们的项目名称包含在 DocumentFile#DocumentFileVersions#filePath

字段中

我现在的问题是,是否可以从 @TextIndexed 中排除字段 filePath

如果 DocumentFileVersion 在您的控制之下,那么您可以仅将 @TextIndexed 添加到 DocumentFileVersion 中您希望索引的那些属性,只需忽略 filePath .

另一种方法是通过 IndexOperations 手动设置索引。也许您想看看 examples project.