我的data-config.xml如下所示,我和solrconfig.xml一起保存在Conf文件夹中: -
<dataConfig>
<dataSource name="Sample" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/Sample" user="postgres" password="P@ssword">
<document name="oneDocs">
<entity dataSource="Sample" name="entity1" query="select FirstName from Employee">
<field column="EmpId" name="EmpId" />
<field column="FirstName" name="FirstName" />
<field column="LastName" name="LastName" />
</entity>
</document>
</dataSource>
</dataConfig>
我的solrconfig.xml如下: -
<requestHandler name="/dataimport"
class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
我还试图通过以下方式添加库: -
<lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />
<lib dir="../../../contrib/dataimporthandler/lib/" regex=".*\.jar" />
<lib dir="../../dist/" regex="solr-dataimporthandler-\d.*\.jar" />
<lib dir="../../dist/" regex="postgresql-9.2-1002.jdbc3-\d.*\.jar" />
<lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />
<lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />
<!-- If a 'dir' option (with or without a regex) is used and nothing
is found that matches, it will be ignored
-->
<lib dir="/total/crap/dir/ignored" />
我经常遇到同样的错误: -
org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config problem: DataImportHandler configuration file must have one <document> node.
at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:226)
at org.apache.solr.handler.dataimport.DataImporter.maybeReloadConfiguration(DataImporter.java:124)
at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:168)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1797)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:637)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:343)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:141)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: DataImportHandler configuration file must have one <document> node.
at org.apache.solr.handler.dataimport.DataImporter.readFromXml(DataImporter.java:250)
at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:223)
... 32 more
请帮助解决这个问题。这大部分时间都在吃掉。感谢
注意:我使用的是Postgres和Apache Tomcat 7以及Java 7.
答案 0 :(得分:3)
您的 data-config.xml 存在缺陷。您已将文档元素包装到数据源元素中。两者都需要与dataConfig元素的直接子级处于同一级别。
这就是您发布的例外情况的原因:
Data Config问题:DataImportHandler配置文件必须具有 一个节点。
XML解析器未将document元素作为dataConfig的子节点。
试试这样:
<dataConfig>
<dataSource name="Sample" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/Sample" user="postgres" password="P@ssword" />
<document name="oneDocs">
<entity dataSource="Sample" name="entity1" query="select FirstName from Employee">
<field column="EmpId" name="EmpId" />
<field column="FirstName" name="FirstName" />
<field column="LastName" name="LastName" />
</entity>
</document>
</dataConfig>
答案 1 :(得分:1)
在data-config.xml
中,document
元素应该是dataSource
元素的兄弟,而不是孩子。
即它看起来应该是这样的;
<dataConfig>
<dataSource>
..
</dataSource>
<document>
..
</document>
</dataConfig>