【发布时间】:2016-03-09 12:39:00
【问题描述】:
我在导入不包含所有必需字段的 xml 时遇到困难。因此我需要将这些字段的值作为“NA”或其他内容传递。 如何在 solr 的 dataimporthandler 模块中使用 XPathEntityprocessor 来做到这一点。 我的 data-config.xml 如下所示:
<dataConfig>
<dataSource type="FileDataSource" />
<document>
<entity name="document"
pk="image_link"
url="/Users/home/file.xml"
processor="XPathEntityProcessor"
forEach="/rss/channel/item"
>
<field column="cp_id" xpath="/rss/channel/item/productid" />
<field column="title" xpath="/rss/channel/item/title" />
<field column="description" xpath="/rss/channel/item/description" />
<field column="link" xpath="/rss/channel/item/link" />
<field column="image_link" xpath="/rss/channel/item/imagelink" />
<field column="category_name" xpath="/rss/channel/item/categoryname" />
<field column="sub_category_name" xpath="/rss/channel/item/subcategoryname" />
<field column="brand" xpath="/rss/channel/item/brand" />
<field column="mrp" xpath="/rss/channel/item/originalprice" />
<field column="offer_price" xpath="/rss/channel/item/discountedprice" />
<field column="source">sometext</field>
<field column="master_category" name="X"/>
<field column="master_category1" name="X"/>
<field column="master_category2" name="X" />
<field column="discount" xpath="/rss/channel/item/availability" />
<field column="comparison" name="0" />
</entity>
</document>
这里我需要添加一个指定了固定值的源列。
谢谢
【问题讨论】: