Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-8541

NPE in spatial field highlighting

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.3, 5.4
    • 5.5
    • None
    • None

    Description

      I prepared a failing test. This worked for 4.x versions. This fails with different stacktrace on 5.1 and 5.0 versions. I'm not sure if it is related to Solr or Lucene. Since the stack trace is different before 5.2 maybe something changed here SOLR-5855?

      test code:

      public class Test extends SolrTestCaseJ4 {
        @BeforeClass
        public static void beforeClass() throws Exception {
          initCore("solrconfig.xml", "schema.xml");
        }
      
        @Test
        public void testConstantScoreQueryWithFilterPartOnly() {
          final String[] doc1 = {"id", "1", "location", "56.9485,24.0980"};
          assertU(adoc(doc1));
          assertU(commit());
      
          ModifiableSolrParams params = new ModifiableSolrParams();
          params.add("q", "{!geofilt sfield=\"location\" pt=\"56.9484,24.0981\" d=100}");
          params.add("hl", "true");
          params.add("hl.fl", "location");
          assertQ(req(params), "*[count(//doc)=1]", "count(//lst[@name='highlighting']/*)=1");
        }
      }
      

      solrconfig:

      <?xml version="1.0" ?>
      <config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
          <dataDir>${solr.data.dir:}</dataDir>
          <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>
      
          <queryResponseWriter name="xml" default="true" class="solr.XMLResponseWriter" />
          <requestHandler name="/select" class="solr.SearchHandler" />
          <requestHandler name="/update" class="solr.UpdateRequestHandler"  />
      </config>
      

      schema:

      <schema name="example" version="1.1">
        <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
        <fieldType name="double" class="solr.TrieDoubleField" sortMissingLast="true" omitNorms="true"/>
        <fieldType name="int" class="solr.TrieIntField" sortMissingLast="true" omitNorms="true"/>
        <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" units="degrees" geo="true" />
      
        <field name="_version_" type="string"/>
        <field name="id" type="string" required="true"/>
        <field name="string_field" type="string"/>
        <field name="double_field" type="double"/>
        <field name="int_field" type="int"/>
        <field name="location" type="location_rpt" />
      
        <uniqueKey>id</uniqueKey>
      
        <defaultSearchField>string_field</defaultSearchField>
      </schema>
      

      This ends up with:

      Exception during query
      java.lang.RuntimeException
      	at org.apache.lucene.util.BytesRef.deepCopyOf(BytesRef.java:281)
      	at org.apache.lucene.analysis.tokenattributes.BytesTermAttributeImpl.copyTo(BytesTermAttributeImpl.java:51)
      	at org.apache.lucene.analysis.tokenattributes.BytesTermAttributeImpl.clone(BytesTermAttributeImpl.java:57)
      	at org.apache.lucene.util.AttributeSource$State.clone(AttributeSource.java:55)
      	at org.apache.lucene.util.AttributeSource.captureState(AttributeSource.java:280)
      	at org.apache.lucene.analysis.CachingTokenFilter.fillCache(CachingTokenFilter.java:96)
      	at org.apache.lucene.analysis.CachingTokenFilter.incrementToken(CachingTokenFilter.java:70)
      	at org.apache.lucene.index.memory.MemoryIndex.addField(MemoryIndex.java:452)
      	at org.apache.lucene.index.memory.MemoryIndex.addField(MemoryIndex.java:384)
      	at org.apache.lucene.index.memory.MemoryIndex.addField(MemoryIndex.java:359)
      	at org.apache.lucene.index.memory.MemoryIndex.addField(MemoryIndex.java:339)
      	at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.getLeafContext(WeightedSpanTermExtractor.java:384)
      	at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.extract(WeightedSpanTermExtractor.java:215)
      	at org.apache.lucene.search.highlight.WeightedSpanTermExtractor.getWeightedSpanTerms(WeightedSpanTermExtractor.java:506)
      	at org.apache.lucene.search.highlight.QueryScorer.initExtractor(QueryScorer.java:219)
      	at org.apache.lucene.search.highlight.QueryScorer.init(QueryScorer.java:187)
      	at org.apache.lucene.search.highlight.Highlighter.getBestTextFragments(Highlighter.java:196)
      	at org.apache.solr.highlight.DefaultSolrHighlighter.doHighlightingByHighlighter(DefaultSolrHighlighter.java:595)
      	at org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(DefaultSolrHighlighter.java:429)
      	at org.apache.solr.handler.component.HighlightComponent.process(HighlightComponent.java:143)
      	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:273)
      	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:156)
      	at org.apache.solr.core.SolrCore.execute(SolrCore.java:2073)
      	at org.apache.solr.util.TestHarness.query(TestHarness.java:311)
      	at org.apache.solr.util.TestHarness.query(TestHarness.java:293)
      	at org.apache.solr.SolrTestCaseJ4.assertQ(SolrTestCaseJ4.java:725)
      	at org.apache.solr.SolrTestCaseJ4.assertQ(SolrTestCaseJ4.java:718)
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            dsmiley David Smiley
            prog Pawel Rog
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment