You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by Harold Harkema <ha...@embracesbs.com> on 2017/12/19 10:03:33 UTC
NullReferenceException in DrillSideways.Search
Hi,
We have converted our 3.0.3 solution to Lucene 4.8.0-beta00005. Most of it works fine and a lot better/faster! Thanks for the good work!
However we have an issue with DrillSideways.Search.
Is this a known issue or could it be our code?
Or any suggestions where to look or how to troubleshoot this?
This is part of the stacktrace. The rest of the stacktrace is only our code.
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
Harold
RE: NullReferenceException in DrillSideways.Search
Posted by Harold Harkema <ha...@embracesbs.com>.
Thanks for the quick response. I have been struggling a bit more with this and managed to create an unit test that reproduces the error.
This unit test throws an NRE.
You can add this unit test to TestDrillSideways.cs.
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);
}
-----Original Message-----
From: Shad Storhaug [mailto:shad@shadstorhaug.com]
Sent: dinsdag 19 december 2017 11:34
To: dev@lucenenet.apache.org
Subject: RE: NullReferenceException in DrillSideways.Search
Harold,
Thanks for the report.
I took a look and it seems the ReqExclScorer requires a scorer to be passed and it is initially invalid until NextDoc() is called. See https://github.com/apache/lucenenet/blob/a3a12967b250e8e7e5f623f0ba7572ec64f479ac/src/Lucene.Net/Search/ReqExclScorer.cs#L115
Other than that I can't tell you much without seeing a code sample that can be executed to determine exactly why the error is happening and whether this is a bug or by design.
Thanks,
Shad Storhaug (NightOwl888)
-----Original Message-----
From: Harold Harkema [mailto:harold.harkema@embracesbs.com]
Sent: Tuesday, December 19, 2017 5:04 PM
To: dev@lucenenet.apache.org
Subject: NullReferenceException in DrillSideways.Search
Hi,
We have converted our 3.0.3 solution to Lucene 4.8.0-beta00005. Most of it works fine and a lot better/faster! Thanks for the good work!
However we have an issue with DrillSideways.Search.
Is this a known issue or could it be our code?
Or any suggestions where to look or how to troubleshoot this?
This is part of the stacktrace. The rest of the stacktrace is only our code.
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
Harold
RE: NullReferenceException in DrillSideways.Search
Posted by Shad Storhaug <sh...@shadstorhaug.com>.
Harold,
Thanks for the report.
I took a look and it seems the ReqExclScorer requires a scorer to be passed and it is initially invalid until NextDoc() is called. See https://github.com/apache/lucenenet/blob/a3a12967b250e8e7e5f623f0ba7572ec64f479ac/src/Lucene.Net/Search/ReqExclScorer.cs#L115
Other than that I can't tell you much without seeing a code sample that can be executed to determine exactly why the error is happening and whether this is a bug or by design.
Thanks,
Shad Storhaug (NightOwl888)
-----Original Message-----
From: Harold Harkema [mailto:harold.harkema@embracesbs.com]
Sent: Tuesday, December 19, 2017 5:04 PM
To: dev@lucenenet.apache.org
Subject: NullReferenceException in DrillSideways.Search
Hi,
We have converted our 3.0.3 solution to Lucene 4.8.0-beta00005. Most of it works fine and a lot better/faster! Thanks for the good work!
However we have an issue with DrillSideways.Search.
Is this a known issue or could it be our code?
Or any suggestions where to look or how to troubleshoot this?
This is part of the stacktrace. The rest of the stacktrace is only our code.
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
Harold