Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-2322

Spatial sort on optional field may fail in corner cases

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.6.0.Beta1
    • Fix Version/s: 5.6.0.Beta2
    • Component/s: engine
    • Labels:
      None

      Description

      Given an index with a spatial field (say, "location"), it seems that indexing a document with missing location in a separate transaction will prevent the sort from working properly.
      If we index it in a transaction where other documents are indexed, everything works well, though.

      We get that kind of stack trace:

      java.lang.NullPointerException
      	at org.hibernate.search.spatial.impl.CoordinateHelper.coordinate(CoordinateHelper.java:23)
      	at org.hibernate.search.spatial.impl.DistanceCollector$DistanceLeafCollector.collect(DistanceCollector.java:149)
      	at org.apache.lucene.search.MultiCollector$MultiLeafCollector.collect(MultiCollector.java:174)
      	at org.apache.lucene.search.MatchAllDocsQuery$1$1.score(MatchAllDocsQuery.java:57)
      	at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:821)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:535)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:523)
      	at org.hibernate.search.query.engine.impl.LazyQueryState.search(LazyQueryState.java:103)
      	at org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:241)
      	at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:136)
      	at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:114)
      	at org.hibernate.search.query.engine.impl.LuceneHSQuery.getQueryHits(LuceneHSQuery.java:308)
      	at org.hibernate.search.query.engine.impl.LuceneHSQuery.queryEntityInfos(LuceneHSQuery.java:143)
      	at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.list(FullTextQueryImpl.java:202)
      	at org.hibernate.search.jpa.impl.FullTextQueryImpl.getResultList(FullTextQueryImpl.java:157)
      	at org.hibernate.search.test.jpa.SpatialQueryingJPATest.testDistanceSortMissingCoordinatesWholeSegment(SpatialQueryingJPATest.java:260)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      
      

      Test case here: https://github.com/hibernate/hibernate-search/pull/1136

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                yrodiere Yoann Rodière
                Reporter:
                yrodiere Yoann Rodière
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: