我正在尝试查询Solr 8.1.1(使用速度UI(http://localhost:8983/solr/#/ {core_name} / query),还没有幻想),并且需要返回父级(产品),子级(模块)和当将父文档作为一个对象而不是文档的统一列表查询时,孙子(锻炼)。
我已经使用DIH导入了我的索引,如下所示。 DIH导入的调试输出显示 childDocuments 字段和我期望的结构,但是查询索引仅返回平面结构。
大多数消息来源建议我在UI或UI字段中添加fl=*,[child]
或fl=*,[child childFilter=Depth:1]
或[child parentFilter=Depth:0 childFilter=Depth:1]
(我敢肯定无论如何都会返回一个额外的级别),但这似乎没有效果。
我的DIH配置如下:
<document name="productDocument">
<entity name="Product" query="SELECT p.*, '0' AS Depth FROM Solr.Product p">
<field column="ProductId" name="ProductId" />
<field column="Description" name="Description" />
<field column="ProductCode" name="ProductCode" />
<field column="ProductType" name="ProductType" />
<field column="ProductLevel" name="ProductLevel" />
<field column="LearningTime" name="LearningTime" />
<field column="Vendor" name="Vendor" />
<field column="Introduction" name="Introduction" />
<field column="ReleasedDate" name="ReleasedDate" />
<field column="MarketingRank" name="MarketingRank" />
<field column="Price" name="Price" />
<field column="Depth" name="Depth"/>
<field column="QuestionCount" name="QuestionCount"/>
<field column="PassMark" name="PassMark"/>
<field column="IsActive" name="IsActive"/>
<entity child="true" name="Module" query="SELECT m.*, '1' AS Depth FROM Solr.Module m WHERE m.ProductId='${Product.ProductId}'">
<field column="ModuleId" name="ModuleId" />
<field column="ProductId" name="ProductId" />
<field column="Description" name="Description" />
<field column="LearningTime" name="LearningTime" />
<field column="Depth" name="Depth"/>
<field column="Order" name="Order"/>
<field column="IsActive" name="IsActive"/>
<entity child="true" name="Exercise" query="SELECT e.*, '2' AS Depth, '${Product.ProductId}' AS ProductId FROM Solr.Exercise e WHERE e.ModuleId='${Module.ModuleId}'">
<field column="ExerciseId" name="ExerciseId" />
<field column="ModuleId" name="ModuleId" />
<field column="ProductId" name="ProductId" />
<field column="Description" name="Description" />
<field column="Depth" name="Depth"/>
<field column="Order" name="Order"/>
<field column="IsActive" name="IsActive"/>
</entity>
</entity>
</entity>
</document>
托管模式中的相关部分如下:
<field name="ProductId" type="string" indexed="true" stored="true" multiValued="false" />
<!-- docValues are enabled by default for long type so we don't need to index the version field -->
<field name="_version_" type="plong" indexed="false" stored="false"/>
<!-- If you don't use child/nested documents, then you should remove the next two fields: -->
<!-- for nested documents (minimal; points to root document) -->
<field name="_root_" type="string" indexed="true" stored="false" docValues="false" />
<!-- for nested documents (relationship tracking) -->
<field name="_nest_path_" type="_nest_path_" /><fieldType name="_nest_path_" class="solr.NestPathField" />
<field name="_text_" type="text_general" indexed="true" stored="false" multiValued="true"/>
<!-- Product / Root -->
<field name="Description" type="text_general" indexed="true" stored="true" multiValued="false" required="false" />
<field name="ProductCode" type="text_general" indexed="true" stored="true" multiValued="false" required="false" />
<field name="ProductType" type="pint" indexed="true" stored="true" multiValued="false" required="false" />
<field name="ProductLevel" type="text_general" indexed="true" stored="true" multiValued="false" required="false" />
<field name="LearningTime" type="pint" indexed="true" stored="true" multiValued="false" required="false" />
<field name="Vendor" type="string" indexed="true" stored="true" multiValued="false" required="false" />
<field name="Introduction" type="text_general" indexed="true" stored="true" multiValued="false" required="false" />
<field name="ReleasedDate" type="pdate" indexed="true" stored="true" multiValued="false" required="false" />
<field name="MarketingRank" type="pint" indexed="true" stored="true" multiValued="false" required="false" />
<field name="Price" type="pfloat" indexed="true" stored="true" multiValued="false" required="false" />
<field name="Order" type="pint" indexed="true" stored="true" multiValued="false" />
<field name="QuestionCount" type="pint" indexed="true" stored="true" multiValued="false" required="false" />
<field name="PassMark" type="pint" indexed="true" stored="true" multiValued="false" required="false" />
<field name="IsActive" type="boolean" indexed="true" stored="true" multiValued="false" required="false" />
我希望查询的输出与DIH调试输出和DIH结构相匹配。我什至需要什么?任何帮助表示赞赏。