[
https://issues.apache.org/jira/browse/LUCENENET-374?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Digy updated LUCENENET-374:
---------------------------
Attachment: SegmentInfo.patch
Hi Paul,
You are right. I added a few lines to your test case
{code}
Lucene.Net.Store.RAMDirectory ramDir = new
Lucene.Net.Store.RAMDirectory();
Lucene.Net.Index.IndexWriter writer = new
Lucene.Net.Index.IndexWriter(ramDir, new Lucene.Net.Analysis.KeywordAnalyzer(),
true, new Lucene.Net.Index.IndexWriter.MaxFieldLength(1000));
Lucene.Net.Documents.Field field = new
Lucene.Net.Documents.Field("TEST", "mytest",
Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.ANALYZED);
Lucene.Net.Documents.Document doc = new
Lucene.Net.Documents.Document();
doc.Add(field);
writer.AddDocument(doc);
Lucene.Net.Index.IndexReader reader = writer.GetReader();
writer.DeleteDocuments(new Lucene.Net.Index.Term("TEST", "mytest"));
bool iscurrent1 = reader.IsCurrent(); // FALSE as expected
int resCount1 = new
Lucene.Net.Search.IndexSearcher(reader).Search(new TermQuery(new
Term("TEST","mytest"))).Length(); //resCount1=1 ==> correct. No Commit
writer.Commit();
bool iscurrent2 = reader.IsCurrent(); // returns TRUE now -
Incorrect
int resCount2 = new
Lucene.Net.Search.IndexSearcher(reader).Search(new TermQuery(new Term("TEST",
"mytest"))).Length(); //resCount2=1 ==> must be 0 if iscurrent2==true
System.Diagnostics.Debug.Assert(resCount1 != resCount2, "resCount1
& resCount2 shouldn't be equal");
System.Diagnostics.Debug.Assert(iscurrent1 == iscurrent2); //
ASSERT FAILs
{code}
and attached a patch for this.
> IndexReader.IsCurrent returning false positive in some cases
> ------------------------------------------------------------
>
> Key: LUCENENET-374
> URL: https://issues.apache.org/jira/browse/LUCENENET-374
> Project: Lucene.Net
> Issue Type: Bug
> Environment: Lucene 2.9.2.2
> Reporter: Paul Gunn
> Attachments: SegmentInfo.patch
>
>
> I've isolated the issue to a pretty small test case [below].
> Under the covers, it looks like NrtIsCurrent is returning 'true' incorrectly
> when documents are deleted & then committed [but before any other documents
> are added].
> Please let me know if any addition data is needed to repro. Thanks, Paul
> Lucene.Net.Store.RAMDirectory ramDir = new
> Lucene.Net.Store.RAMDirectory();
> Lucene.Net.Index.IndexWriter writer = new
> Lucene.Net.Index.IndexWriter(ramDir, new
> Lucene.Net.Analysis.KeywordAnalyzer(), true, new
> Lucene.Net.Index.IndexWriter.MaxFieldLength(1000) );
> Lucene.Net.Documents.Field field = new
> Lucene.Net.Documents.Field("TEST", "mytest",
> Lucene.Net.Documents.Field.Store.YES,
> Lucene.Net.Documents.Field.Index.ANALYZED);
> Lucene.Net.Documents.Document doc = new
> Lucene.Net.Documents.Document();
> doc.Add(field);
> writer.AddDocument(doc);
> Lucene.Net.Index.IndexReader reader = writer.GetReader();
> writer.DeleteDocuments(new Lucene.Net.Index.Term("TEST",
> "mytest"));
> bool iscurrent1 = reader.IsCurrent(); // FALSE as expected
> writer.Commit();
> bool iscurrent2 = reader.IsCurrent(); // returns TRUE now -
> Incorrect
> System.Diagnostics.Debug.Assert(iscurrent1 == iscurrent2); //
> ASSERT FAILs
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.