lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harold Harkema (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LUCENENET-598) NullReferenceException in DrillSideways.Search - ReqExclScorer.GetCost
Date Tue, 02 Jan 2018 13:00:01 GMT
Harold Harkema created LUCENENET-598:
----------------------------------------

             Summary: NullReferenceException in DrillSideways.Search - ReqExclScorer.GetCost
                 Key: LUCENENET-598
                 URL: https://issues.apache.org/jira/browse/LUCENENET-598
             Project: Lucene.Net
          Issue Type: Bug
          Components: Lucene.Net.Facet
    Affects Versions: Lucene.Net 4.8.0
            Reporter: Harold Harkema
             Fix For: Lucene.Net 4.8.0


We have migrated all our Lucene 3.0 code to Lucene 4.8. However 
when searching with DrillSideways.Search we sometimes get a NullReferenceException with this
stacktrace:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Lucene.Net.Search.ReqExclScorer.GetCost() in C:\BuildAgent\work\b1b63ca15b99dddb\src\Lucene.Net\Search\ReqExclScorer.cs:line
148
   at Lucene.Net.Facet.DrillSidewaysScorer.Score(ICollector collector, Int32 maxDoc) in C:\BuildAgent\work\b1b63ca15b99dddb\src\Lucene.Net.Facet\DrillSidewaysScorer.cs:line
139
   at Lucene.Net.Search.IndexSearcher.Search(IList`1 leaves, Weight weight, ICollector collector)
in C:\BuildAgent\work\b1b63ca15b99dddb\src\Lucene.Net\Search\IndexSearcher.cs:line 649
   at Lucene.Net.Facet.DrillSideways.Search(DrillDownQuery query, ICollector hitCollector)
in C:\BuildAgent\work\b1b63ca15b99dddb\src\Lucene.Net.Facet\DrillSideways.cs:line 194
   at Lucene.Net.Facet.DrillSideways.Search(ScoreDoc after, DrillDownQuery query, Int32 topN)
in C:\BuildAgent\work\b1b63ca15b99dddb\src\Lucene.Net.Facet\DrillSideways.cs:line 249

I managed to reproduce this in an unit test. If you add this unit test for example to TestDrillSideways.cs
it will throw a NullReferenceException when running. This unit test should give 0 results
because the criteria "Age != 23 AND Name == *e*" matches nothing. However I sometimes have
the same issue when the query returns multiple results but that is currently a bit harder
to reproduce in a unit test.

        [Test]
        public virtual void TestFacetNRE()
        {
            Directory dir = NewDirectory();
            Directory taxoDir = NewDirectory();

            // Writes facet ords to a separate directory from the
            // main index:
            var taxoWriter = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);

            FacetsConfig config = new FacetsConfig();

            RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, Similarity, TimeZone);

            Document doc = new Document();
            doc.Add(new Field("Name", "John", Documents.StringField.TYPE_STORED));
            doc.Add(new Field("Age", "19", Documents.StringField.TYPE_STORED));
            doc.Add(new FacetField("Function", "Developer"));
            writer.AddDocument(config.Build(taxoWriter, doc));

            doc = new Document();
            doc.Add(new Field("Name", "Steven", Documents.StringField.TYPE_STORED));
            doc.Add(new Field("Age", "23", Documents.StringField.TYPE_STORED));
            doc.Add(new FacetField("Function", "Sales"));
            writer.AddDocument(config.Build(taxoWriter, doc));

            // NRT open
            IndexSearcher searcher = NewSearcher(writer.Reader);

            // NRT open
            var taxoReader = new DirectoryTaxonomyReader(taxoWriter);

            DrillSideways ds = new DrillSideways(searcher, config, taxoReader);

            var query = new BooleanQuery(true);
            query.Add(new TermQuery(new Term("Age", "23")), Occur.MUST_NOT);
            query.Add(new WildcardQuery(new Term("Name", "*e*")), Occur.MUST);

            var mydrillDownQuery = new DrillDownQuery(config, query);
            mydrillDownQuery.Add("Function", "Developer");

            var z = ds.Search(mydrillDownQuery, null, null, 10, null, false, false);

            IOUtils.Dispose(searcher.IndexReader, taxoReader, writer, taxoWriter, dir, taxoDir);
        }




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message