Configuration Nested Entity using DIH in SOLR

社会主义新天地 提交于 2021-02-08 06:14:33

问题


I wanna create nested entity with DIH using SOLR 6.x

i read Defining nested entities in Solr Data Import Handler

and jira https://issues.apache.org/jira/browse/SOLR-5147

what i did

Schema.xml

<fields>
<field name="variantList" type="string" indexed="true" stored="true"    />
<field name="variantList.variants" type="string" multiValued="false" required="false"/>
<field name="variantList.stockMinimum" type="int" multiValued="false" required="false"/>
<field name="variantList.stockOnHand" type="int" multiValued="false" required="false"/>
<field name="variantList.stockVariantId" type="long" multiValued="false" required="false"/>
</fields>

data-config.xml

<dataConfig>
  <dataSource /> 
  <document>
    <entity name="PARENT" rootEntity='true' query="*" >
     <field column="ID" name="id" />
     <field column="BRAND_ID" name="brandId" />
     <field column="PRODUCT_ID" name="productId" />
     <field column="MERCHANT_PRODUCT_ID" name="merchantProductId" />
     <field column="MERCHANT_ID" name="merchantId" />
     <field column="SALES_REGION" name="salesRegion" />
     <field column="LOCAL_DIRECT_DELIVERY" name="localDirectDelivery" />
     <field column="NORMAL_SELLINGPRICE" name="normalSellingPrice" />
     <field column="NEW_PRODUCT" name="newProduct" />
     <field column="BEST_SELLER" name="bestSeller" />
     <field column="CATEGORY1_ID" name="category1Id" />
     <field column="CATEGORY2_ID" name="category2Id" />
     <field column="CATEGORY3_ID" name="category3Id" />
     <field column="CATEGORY4_ID" name="category4Id" />
     <field column="DISPLAY_IMAGE_PATH" name="displayImagePath" />
     <field column="MERCHANT_NAME" name="merchantName" />
     <field column="PRODUCT_NAME" name="productName" />
     <field column="CATEGORY1_NAME" name="category1Name" />
     <field column="CATEGORY2_NAME" name="category2Name" />
     <field column="CATEGORY3_NAME" name="category3Name" />
     <field column="CATEGORY4_NAME" name="category4Name" />





        <entity name="variantList" child="true" query="select VARIANT , STOCK_MINIMUM , STOCK_ONHAND , ID from SIF_MERCHANT_CATALOG_VARIANT 
                                                    where MERCHANT_CATALOG_ID = '${PARENT.ID}'">
                <field column="VARIANT" name="variantList.variants_s" />
                <field column="STOCK_MINIMUM" name="variantList.stockMinimum" />
                <field column="STOCK_ONHAND" name="variantList.stockOnHand" />
                <field column="ID" name="variantList.stockVariantId" />
            </entity>
    </entity>
  </document>
</dataConfig>

result that i want

<doc parent_1/>
  <doc child_1/>
  <doc child_1/>
<doc parent_2/>
  <doc child_1/>

and what i get

<doc child_1/>
<doc child_1/>
<doc parent_1/>
<doc child_2/>
<doc parent_2/>

and i see aheryan's anwers , it should be right , i can use child=true

am i miss something ?

thanks


回答1:


The child docs are returned together with parent docs if you just do a general query. As a flat list. So, that's probably what you are seeing.

The easiest way to check whether you got nested documents is to look at the value of the _root_ field, as the value will be the same for all documents in the parent/child hierarchy block.

You could also search for parent documents only and use Child Document Transformer to list its children.



来源:https://stackoverflow.com/questions/40838090/configuration-nested-entity-using-dih-in-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!