【问题标题】:adding a custom field column while importing using xpath in solr在 solr 中使用 xpath 导入时添加自定义字段列
【发布时间】: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>

这里我需要添加一个指定了固定值的源列。

谢谢

【问题讨论】:

    标签: xml xpath solr


    【解决方案1】:

    我找到了一个解决方案 我使用了 TemplateTransformer 并将“NA”添加到名为 source 的字段列中。

    <field column="source"  template="NA"/>
    

    有关 solr 中数据导入处理程序中的转换器的更多信息。请参阅此链接: https://cwiki.apache.org/confluence/display/solr/Uploading+Structured+Data+Store+Data+with+the+Data+Import+Handler

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-13
      相关资源
      最近更新 更多