【发布时间】:2017-11-14 18:00:51
【问题描述】:
我正在尝试使用 DIH 从我不维护的 XML 源导入数据。此 XML 具有分组为属性的可选元素,例如颜色或风味。并非所有实体都具有所有属性,这是非常好的和有效的。可悲的是,当我仍然需要这些实体时,DIH 会跳过它们。这是我的 data-config.xml
<dataConfig>
<dataSource type="FileDataSource" name="datasource"/>
<document>
<entity
name="files"
processor="FileListEntityProcessor"
baseDir="C:\\"
fileName="recipe_page.*xml"
recursive="false"
rootEntity="false"
dataSource="null">
<entity
name="file"
processor="XPathEntityProcessor"
url="${files.fileAbsolutePath}"
forEach="/results|/results/recipe"
stream="true"
transformer="TemplateTransformer">
<field column="recipe_id" xpath="/results/recipe/recipeID" />
<field column="recipe_title" xpath="/results/recipe/recipeTitle" />
<field column="color" xpath="/results/recipe/attributes/Color" default="" />
<field column="drink_classification" xpath="/results/recipe/attributes/DrinkClassification" default="" />
<field column="flavor" xpath="/results/recipe/attributes/Flavor" default="" />
<field column="uid" template="recipe_${file.recipe_id}" />
<field column="document_type" template="recipe" />
</entity>
</entity>
</document>
</dataConfig>
如何让 DIH 忽略缺失的元素或至少为这些元素设置默认值?
【问题讨论】:
标签: xml solr dataimporthandler dih