Solr 嵌套文档未正确设置

Yir*_*her 5 solr solr8

我正在尝试使用子文档创建 solr 文档。我正在使用 solr 8.2.0 为了遵守https://lucene.apache.org/solr/guide/8_0/indexing-nested-documents.html#indexing-nested-documents 中的说明,我添加了以下内容架构.xml

<field name="_root_" type="string" indexed="true" stored="false"/>
<fieldType name="nest_path" class="solr.NestPathField" />
<field name="_nest_path_" type="nest_path" />
<field name="_nest_parent_" type="string" indexed="true" stored="true"/>
Run Code Online (Sandbox Code Playgroud)

为了创建一个测试文档,我使用了以下 PHP 代码:

$solrClient = ...
$solrInputDocument = new SolrInputDocument();
$solrInputDocument->addField('id', 'yirmi1', 1);
$solrInputDocument->addField('test_s', 'this is a parent test', 1);
$childDoc = new SolrInputDocument();
$childDoc->addField('id', 'yirmi2', 1);
$childDoc->addField('test_s', 'this is a child test', 1);
$solrInputDocument->addChildDocument($childDoc);
$solrUpdateResponse = $solrClient->addDocument($solrInputDocument);
$solrClient->commit();
Run Code Online (Sandbox Code Playgroud)

当我查询fq=id: "yirmi1"or 时fq=id: "yirmi2",记录出现,但没有迹象表明存在父文档或子文档。此外,当查询字段_nest_parent__nest_path__root_时,即使我将它们指定为查询字段也不会出现。

我还需要设置什么才能正确创建嵌套文档。

小智 0

你添加了吗fl=*,[child]?那应该返回childDocuments

我承认我是 SOLR 的新手,而且我还没有取得 100% 的成功。:(