简体   繁体   English

使用Solr Dataimporthandler索引XML属性值

[英]Index xml attribute value with Solr Dataimporthandler

I need to index some XML documents which make use of namespaces, such as: 我需要索引一些使用命名空间的XML文档,例如:

<pm:Kroot>
<pm:root>
    <pm:meta>
        <dc:id xmlns:dc="http://purl.org/dc/elements/1.1/">1</dc:id>
        <dc:source>
            <dc:source>
                <pm:link pm:description="Tele" pm:source="8326"/>
            </dc:source>
        </dc:source>
    </pm:meta>
</pm:root>
</pm:Kroot>

Now when I use the the below DataImport, Solr manages to get the ID but it fails to index the Attributes values: 现在,当我使用下面的DataImport时,Solr设法获取ID,但无法为Attributes值建立索引:

<dataConfig>
 <dataSource  type="FileDataSource" encoding="UTF-8" />
 <document>
    <entity name="article"
            url="/sample.xml"
            processor="XPathEntityProcessor"
            stream="true"                               
            forEach="/Kroot/root" >


        <field column="id"              xpath="/Kroot/root/meta/id" />            
        <field column="news_id"    xpath="/Kroot/root/meta/source/source/link/@source" />
        <field column="news_name"  xpath="/Kroot/root/meta/source/source/link/@description" />

   </entity>
 </document>

By removing the attribute namespaces from the XML file, Solr manages to index all the data! 通过从XML文件中删除属性名称空间,Solr设法索引所有数据! Now I am searching for a solution and I cant find an explanation for this behavior. 现在,我正在寻找解决方案,但找不到这种行为的解释。 The Solr wiki says that in case of namespaces we should use only the attribute name without the namespace, just like I do. Solr Wiki表示,在命名空间的情况下,就像我一样,我们应该仅使用属性名称而不使用命名空间。 I am using Solr 4.1 btw. 我正在使用Solr 4.1 btw。

您可以尝试例如/Kroot/root/meta/source/source/link[@description]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM