[英]Solr DataImportHandler doesn't work with XML Files
我是Solr的新手。 我通过DIH成功索引了我的sql数据库中的数据。 现在,我想导入xml文件并通过DIH将它们编入索引,但这根本行不通! 我的data-config.xml看起来像这样:
<dataConfig>
<dataSource type="FileDataSource" encoding="UTF-8" />
<document>
<entity name="dir"
processor="FileListEntityProcessor"
baseDir="/bla/test2"
fileName=".*xml"
stream="true"
recursive="false"
rootEntity="false">
<entity name="PubmedArticle"
processor="XPathEntityProcessor"
transformer="RegexTransformer"
stream="true"
forEach="/PubmedArticle"
url="${dir.fileAbsolutePath}">
<field column="journal" xpath="//Name[.='journal']/following-sibling::Value/text()" />
<field column="authors" xpath="//Name[.='authors']/following-sibling::Value/text()" />
..etc
而且我在schema.xml中具有以下字段:
<field name="journal" type="text" indexed="true" stored="true" required="true" /> <field name="authors" type="text" indexed="true" stored="true" required="true" />
当我运行Solr时,我没有收到任何错误,也没有索引任何文档:
<str name="Total **Rows Fetched**">**2000**</str>
<str name="Total **Documents Skipped**">**0**</str>
<str name="Full Dump Started">2012-02-01 14:59:17</str>
<str name="">Indexing completed. **Added/Updated: 0 documents.** Deleted 0 documents.
谁能告诉我我做错了吗? 我什至仔细检查了路径语法...
我最近在尝试相同的事情时遇到了相同的问题。 即,当使用FileListEntityProcessor (读取多个本地.xml文件)和XPathEntityProcessor (获取某些XML元素)时。
根本原因 :在此行中:
<field column="journal" xpath="//Name[.='journal']/following-sibling::Value/text()" />
说明 :xpath属性(“ // Name ...”)的参数虽然有效,但xpath语法不受Solr支持。 “ Apache Solr 4.4参考指南”只是说: XPath表达式将从该字段的记录中提取内容。 仅支持Xpath语法的子集。
解决方案 :将xpath的参数更改为文档根目录的完整路径:
<field column="journal" xpath="/full/path/from/root/of/document/Name[.='journal']/following-sibling::Value/text()" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.