我正在尝试使用子文档创建 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_时,即使我将它们指定为查询字段也不会出现。
我还需要设置什么才能正确创建嵌套文档。
| 归档时间: |
|
| 查看次数: |
862 次 |
| 最近记录: |