简体   繁体   English

Apache Solr DataImportHandler尝试索引失败

[英]Apache Solr DataImportHandler failes trying to index

I am trying to index some xml files into Solr 6.2.1 using their DataImportHandler. 我正在尝试使用它们的DataImportHandler将一些xml文件索引到Solr 6.2.1中。

For that purpose I have added the needed import and this RequestHandler into the solrconfig.xml: 为此,我已将所需的导入和此RequestHandler添加到solrconfig.xml中:

  <lib dir="${solr.install.dir:../../../..}/contrib/dataimporthandler/lib/" regex=".*\.jar" />
  <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-.*\.jar" />

  <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler" startup="lazy">
    <lst name="default">
        <str name="config">data-config.xml</str>
    </lst>
  </requestHandler>

Then I wrote the data-config.xml and put it into the same path as the solrconfig.xml: 然后,我编写了data-config.xml并将其放入与solrconfig.xml相同的路径中:

<dataConfig>
    <dataSource type="FileDataSource" encoding="UTF-8"/>
    <document>
        <entity name="pickupdir"
                processor="FileListEntityProcessor"
                dataSource="null"
                baseDir="/vagrant/TREC8all/Adhoc/"
                recursive="true"
                fileName="^[\w\d-]+\.xml$" />
        <entity name="trec8_simple"
                processor="XPathEntityProcessor"
                stream="true"
                datasource="pickupdir"
                url="${pickupdir.fileAbsolutePath}"
                forEach="/DOCS/DOC">
            <field column="id" xpath="/DOCS/DOC/DOCNO"/>
            <field column="header" xpath="/DOCS/DOC/HEADER"/>
            <field column="text" xpath="/DOCS/DOC/TEXT"/>
        </entity>
    </document>
</dataConfig>

This should make the ImportHandler iterate recursively through all xml files in the directory and index them according to the xpaths. 这应该使ImportHandler递归遍历目录中的所有xml文件,并根据xpath对其进行索引。

When I call the requestHandler like this: (I am running solr in a vagrant box instead of locally) 当我这样调用requestHandler时:(我在无业游民的盒子中而不是在本地运行solr)

http://192.168.155.156:8983/solr/trec8/dataimport?command=full-import&entity=trec8_simple

I am getting this Exception in the solr.log: 我在solr.log中收到此异常:

ERROR (Thread-14) [   x:trec8] o.a.s.h.d.DataImporter Full Import failed:java.lang.NullPointerException
        at org.apache.solr.handler.dataimport.DataImporter.createPropertyWriter(DataImporter.java:325)
        at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:412)
        at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:475)
        at org.apache.solr.handler.dataimport.DataImporter.lambda$runAsync$0(DataImporter.java:458)
        at java.lang.Thread.run(Thread.java:745)

Im assuming this should be the source for the DataImportHandler: 我假设这应该是DataImportHandler的来源:

https://github.com/sudarshang/lucene-solr/blob/master/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/DataImporter.java https://github.com/sudarshang/lucene-solr/blob/master/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/DataImporter.java

I have trouble figuring out what is causing this exception and what it is meaning. 我很难弄清楚是什么导致了这个异常及其含义。 Would be nice if somebody could help me out. 如果有人可以帮助我,那会很好。 Thanks! 谢谢!

EDIT: I think this has something to do with the DataImportHandler not beeing able to finde the data-config.xml. 编辑:我认为这与DataImportHandler无关,无法找到data-config.xml。 When I remove it will throw the exact same exception 当我删除它会抛出完全相同的异常

Ok I found the issue! 好的,我发现了问题! Problem was in the solrconfig, 问题出在solrconfig中,

<lst name="default">
    <str name="config">data-config.xml</str>
</lst>

should have been 本来应该

<lst name="defaults">
    <str name="config">data-config.xml</str>
</lst>

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

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