【发布时间】:2020-04-21 07:12:35
【问题描述】:
我正在尝试使用子文档创建 solr 文档。我正在使用 solr 8.2.0 为了遵守 https://lucene.apache.org/solr/guide/8_0/indexing-nested-documents.html#indexing-nested-documents 中的说明,我在 schema.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"/>
为了创建测试文档,我使用了以下 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();
当我查询fq=id: "yirmi1" 或fq=id: "yirmi2" 时,
记录出现了,但没有迹象表明有父文件或子文件。此外,当查询_nest_parent_、_nest_path_ 和_root_ 字段时,即使我将它们指定为查询字段,也不会出现。
我还需要设置什么才能正确创建嵌套文档。
【问题讨论】:
-
嘿,添加子文档成功了吗?我也有同样的问题