首页 > 解决方案 > Spring Data Solr - 支持本机(不是“匿名”或“未标记”)嵌套/子文档?

问题描述

据我了解,从 Solr 8 开始,有一种处理嵌套/子文档的新方法。

经典的 Solr 方式现在被称为“匿名”或“未标记”子文档。

以某种新方式支持 Spring Data Solr?
有人可以通过存储库编写两个 VO、save() 和 findAll() 的最简单示例吗?

首先 - 如何定义 VO?

@SolrDocument
public class ParentIndex {

    @Id
    @Indexed
    private String id;

    @ChildDocument//??
    @Field(child = true)//??
    private List<ChildIndex> childs;
}

@SolrDocument//SolrDocument on child??
public class ChildIndex {

    @Id//child id??
    @Indexed
    private String id;

    @Indexed
    private String data;
}

第二 - 如何定义架构?

@EnableSolrRepositories(schemaCreationSupport = true) 不要创建这样的东西:

<field name="_root_" type="string" docValues="false" indexed="true" stored="false"/>
<field name="id" type="string" multiValued="false" required="true" stored="true"/>

<fieldType name="_nest_path_" class="solr.NestPathField"/>
<field name="_ChildIndex_" type="_nest_path_">  //where to get name value ??
    <field name="id" type="string" multiValued="false" required="true" stored="true"/>
    <field name="data" type="string" indexed="true" stored="true"/>
</field>

如何在我的 Solr schema.xml 中表示子文档?
Solr 嵌套文档未正确设置

第三 - 如何在存储库方法上使用 [child]

是否有必要检索孩子的VO?

标签: solrspring-data-solr

解决方案


推荐阅读