突出显示不起作用:HighlightComponent.process()第139行中的NullPointerException

时间:2014-09-04 12:43:27

标签: solr solr4 solr-highlight

尝试在Solr 4.7.2中进行简单的突出显示。我正在构建示例中提供的标准solrconfig.xml。我已经修改了/select请求处理程序:

<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="defaults">
        <str name="echoParams">explicit</str>
        <int name="rows">10</int>
        <str name="df">text</str>
    </lst>

    <!-- Highlighting defaults -->
    <str name="hl">off</str>
    <str name="hl.fl">content title</str>
    <str name="hl.encoder">html</str>
    <str name="f.title.hl.fragsize">0</str>
    <str name="f.title.hl.alternateField">title</str>
    <str name="f.name.hl.fragsize">0</str>
    <str name="f.name.hl.alternateField">name</str>
    <str name="f.content.hl.snippets">3</str>
    <str name="f.content.hl.fragsize">200</str>
    <str name="f.content.hl.alternateField">content</str>
    <str name="f.content.hl.maxAlternateFieldLength">750</str>

    <arr name="components">
        <str>highlight</str>
        <str>spellcheck</str>
        <str>query</str>
    </arr>
</requestHandler>

但是当我执行搜索时,我得到了一个N​​PE:

<response>
    <lst name="responseHeader">
        <int name="status">500</int>
        <int name="QTime">6</int>
        <lst name="params">
            <str name="indent">false</str>
            <str name="start">0</str>
            <str name="q">text:Home</str>
            <str name="wt">xml</str>
            <str name="hl">true</str>
            <str name="rows">10</str>
        </lst>
    </lst>
    <lst name="error">
        <str name="trace">
            java.lang.NullPointerException 
                at org.apache.solr.handler.component.HighlightComponent.process(HighlightComponent.java:139) 
                at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:217) 
                at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135) 
                at org.apache.solr.core.SolrCore.execute(SolrCore.java:1916) 
                at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:768) 
                at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:415) 
                at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:205) 
                at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419) 
                at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455) 
                at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) 
                at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557) 
                at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) 
                at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075) 
                at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384) 
                at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) 
                at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009) 
                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:368) 
                at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) 
                at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53) 
                at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942) 
                at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004) 
                at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640) 
                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:662)
        </str>
        <int name="code">500</int>
    </lst>
</response>

如果我从solrconfig.xml中删除<str>highlight</str>,则查询有效。我正在执行的查询是:

http://localhost:8983/solr/portal_search/select?q=text%3AHome&start=0&rows=10&wt=xml&indent=false&hl=true

1 个答案:

答案 0 :(得分:1)

这可能是你的错误:

https://issues.apache.org/jira/browse/SOLR-6070

我正在运行4.9并试图使用两个不同的名称荧光笔遇到同样的问题。使用命名的一个爆炸,让它默认为默认“只是工作”。

如果您只需要一个荧光笔,则无需使用“&lt; str&gt;高亮显示&lt; / str&gt;” - 这是要查找的(显然是当前硬编码的)默认名称(请参阅https://cwiki.apache.org/confluence/display/solr/RequestHandlers+and+SearchComponents+in+SolrConfig)。