1

我正在使用 solr 来索引 pdf 和 doc 文件。我正在使用 bitnami 堆栈(http://bitnami.com/stack/solr

现在我将以下代码添加到我的 c# 应用程序中:

    string filecontent = null;

    using (var file = File.OpenRead(@"C:\\cookbook.pdf"))
    {
        var response = solr.Extract(new ExtractParameters(file, "abcd1")
        {
            ExtractOnly = true,
            ExtractFormat = ExtractFormat.Text,
        });

        filecontent = response.Content;
    }
    solr.Commit();

这就是我到目前为止所做的,请参阅来自 C# 客户端的 Solr 中的索引 pdf 文档

不幸的是,我总是遇到以下异常:

SolrNet.Exceptions.SolrConnectionException was unhandled
  HResult=-2146232832
  Message=<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="error"><str name="msg">lazy loading error</str><str name="trace">org.apache.solr.common.SolrException: lazy loading error
    at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.getWrappedHandler(RequestHandlers.java:258)
    at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.handleRequest(RequestHandlers.java:240)
    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:642)
    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(Thread.java:722)
Caused by: org.apache.solr.common.SolrException: Error loading class 'solr.extraction.ExtractingRequestHandler'
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:440)
    at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:519)
    at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:593)
    at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.getWrappedHandler(RequestHandlers.java:249)
    ... 30 more
Caused by: java.lang.ClassNotFoundException: solr.extraction.ExtractingRequestHandler
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:789)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:266)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:424)
    ... 33 more
</str><int name="code">500</int></lst>
</response>

  Source=SolrNet
  Url=http://berserkerpc:444/solr/update/extract?literal.id=abcd1&resource.name=C:%5ccookbook.pdf&extractOnly=true&extractFormat=text&version=2.2
  StackTrace:
       bei SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Impl\SolrConnection.cs:Zeile 119.
       bei SolrNet.Commands.ExtractCommand.Execute(ISolrConnection connection) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Commands\ExtractCommand.cs:Zeile 36.
       bei SolrNet.Impl.SolrBasicServer`1.Send(ISolrCommand cmd) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Impl\SolrBasicServer.cs:Zeile 102.
       bei SolrNet.Impl.SolrBasicServer`1.SendAndParseExtract(ISolrCommand cmd) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Impl\SolrBasicServer.cs:Zeile 106.
       bei SolrNet.Impl.SolrBasicServer`1.Extract(ExtractParameters parameters) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Impl\SolrBasicServer.cs:Zeile 83.
       bei SolrNet.Impl.SolrServer`1.Extract(ExtractParameters parameters) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Impl\SolrServer.cs:Zeile 133.
       bei SolrTest.Program.IndexPDFFile(ISolrOperations`1 solr) in c:\Users\troth\Desktop\SolrTest\SolrTest\Program.cs:Zeile 35.
       bei SolrTest.Program.Main(String[] args) in c:\Users\troth\Desktop\SolrTest\SolrTest\Program.cs:Zeile 21.
       bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.WebException
       HResult=-2146233079
       Message=Der Remoteserver hat einen Fehler zurückgegeben: (500) Interner Serverfehler.
       Source=System
       StackTrace:
            bei System.Net.HttpWebRequest.GetResponse()
            bei HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse() in c:\Users\troth\Desktop\SolrNet-master\HttpWebAdapters\Impl\HttpWebRequestAdapter.cs:Zeile 36.
            bei SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Impl\SolrConnection.cs:Zeile 193.
            bei SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters) in c:\Users\troth\Desktop\SolrNet-master\SolrNet\Impl\SolrConnection.cs:Zeile 111.
       InnerException:

任何提示我可以做些什么来解决这个问题?

谢谢,特罗

4

2 回答 2

2

在检查错误日志时,这似乎是这里的主要问题:

引起:org.apache.solr.common.SolrException:加载类“solr.extraction.ExtractingRequestHandler”时出错

Solr 似乎无法加载 solr.extraction.ExtractingRequestHandler 类。

您是否按照您提供的链接中的步骤将 Solr Cell 和提取 jar 文件添加到您的 Solr 安装可以从中加载它们的库文件夹中?

于 2013-03-28T15:06:11.707 回答
0

知道了!问题出在 solrconfig.xml 文件中。我不得不粘贴以下代码:

<lib dir="../../extract" regex=".*\.jar" />

  <requestHandler name="/update/extract" 
                  startup="lazy"
                  class="solr.extraction.ExtractingRequestHandler" >
    <lst name="defaults">
      <str name="lowernames">true</str>
      <str name="uprefix">ignored_</str>

      <!-- capture link hrefs but ignore div attributes -->
      <str name="captureAttr">true</str>
      <str name="fmap.a">links</str>
      <str name="fmap.div">ignored_</str>
    </lst>
  </requestHandler>

感谢您的帮助!

特罗

于 2013-03-29T09:34:21.370 回答