Highlighting not working: NullPointerException in HighlightComponent.process() line 139

350 views Asked by At

Trying to get simple highlighting working in Solr 4.7.2. I am building off the standard solrconfig.xml provided in the examples. I have doctored up the /select request handler as such:

<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>

But when I execute a search I get a NPE:

<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>

If I remove the <str>highlight</str> from the solrconfig.xml then the query works. The query I am executing is:

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

There are 1 answers

0
Foobie Bletch On

This might be your bug:

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

I'm running 4.9 and hitting the same problem trying to use two different named highlighters. Using a named one blows up, letting it default to the default "just works."

If you only need one highlighter, you don't need to have the "<str>highlight</str>" -- this is the default name that it's (apparently currently hardcoded) to look for (see https://cwiki.apache.org/confluence/display/solr/RequestHandlers+and+SearchComponents+in+SolrConfig).