lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeroen Lauwers <Jeroen.Lauw...@CTLO.NET>
Subject RE: problem with deleting document
Date Fri, 28 Nov 2008 08:44:07 GMT
You wrote in CODE 3:
IndexDirectory = Lucene.Net.Store.FSDirectory.GetDirectory(@"D:\INDEX", ---> TRUE <----)

I assume this should be:
IndexDirectory = Lucene.Net.Store.FSDirectory.GetDirectory(@"D:\INDEX", ---> FALSE <----)

I think you do not want to re-create the directory!
Typo?

Jeroen

-----Original Message-----
From: Landrix SE - Sven Harazim [mailto:sh@landrix.de]
Sent: vrijdag 28 november 2008 9:14
To: lucene-net-dev@incubator.apache.org
Subject: problem with deleting document

Hello,

i'm using the current SVN-Version of Lucene.net.

First, i create an index with some documents (3 items).
See CODE 1 below.


I delete one document with indexreader. Luke Index Viewer show this correct.
See CODE 2 below

I update one document
See Code 3 below


Then, the index contains only this one document. All other documents were deleted.

What's happen?

CODE 1
#########################################################
Lucene.Net.Store.Directory IndexDirectory;
Lucene.Net.Analysis.Analyzer Analyzer;
Lucene.Net.Index.IndexWriter IndexWriter;
IndexDirectory = Lucene.Net.Store.FSDirectory.GetDirectory(@"D:\INDEX", true);
Analyzer = new Lucene.Net.Analysis.DE.GermanStandardAnalyzer(); //0
IndexWriter = new Lucene.Net.Index.IndexWriter(IndexDirectory, false, Analyzer); //AutoCommit
nur bei Close
Lucene.Net.Documents.Document aDoc = new Lucene.Net.Documents.Document();
Lucene.Net.Documents.Field fld = new Lucene.Net.Documents.Field("id", "A2008-0005", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.UN_TOKENIZED, Lucene.Net.Documents.Field.TermVector.NO);
aDoc.Add(fld);
IndexWriter.AddDocument(aDoc);
aDoc = new Lucene.Net.Documents.Document();
fld = new Lucene.Net.Documents.Field("id", "A2008-0006", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.UN_TOKENIZED, Lucene.Net.Documents.Field.TermVector.NO);
aDoc.Add(fld);
IndexWriter.AddDocument(aDoc);
aDoc = new Lucene.Net.Documents.Document();
fld = new Lucene.Net.Documents.Field("id", "A2008-0007", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.UN_TOKENIZED, Lucene.Net.Documents.Field.TermVector.NO);
aDoc.Add(fld);
IndexWriter.AddDocument(aDoc);
IndexWriter.Optimize();
IndexWriter.Close();


CODE 2
############################################################
Lucene.Net.Index.Term deleteTerm = new Lucene.Net.Index.Term("id","A2008-0006");
Lucene.Net.Store.Directory directory = Lucene.Net.Store.FSDirectory.GetDirectory(@"D:\INDEX",
false);
Lucene.Net.Index.IndexReader reader = Lucene.Net.Index.IndexReader.Open(directory);
reader.DeleteDocuments(deleteTerm);
reader.Close();
directory.Close();


CODE 3
##########################################################
Lucene.Net.Store.Directory IndexDirectory;
Lucene.Net.Analysis.Analyzer Analyzer;
Lucene.Net.Index.IndexWriter IndexWriter;
Lucene.Net.Index.Term aUpdateTerm = new Lucene.Net.Index.Term("id", "A2008-0005");
Lucene.Net.Documents.Document aDoc = new Lucene.Net.Documents.Document();
Lucene.Net.Documents.Field fld = new Lucene.Net.Documents.Field("id", "A2008-0005", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.UN_TOKENIZED, Lucene.Net.Documents.Field.TermVector.NO);
aDoc.Add(fld);
IndexDirectory = Lucene.Net.Store.FSDirectory.GetDirectory(@"D:\INDEX", true);
Analyzer = new Lucene.Net.Analysis.DE.GermanStandardAnalyzer();
IndexWriter = new Lucene.Net.Index.IndexWriter(IndexDirectory,false, Analyzer); //AutoCommit
nur bei Close
IndexWriter.UpdateDocument(aUpdateTerm,aDoc);
IndexWriter.Optimize();
IndexWriter.Close();


Thanks,

Sven




Mime
View raw message