lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Svensson <si...@devhost.se>
Subject RE: Update Document In existing Index File
Date Thu, 01 Aug 2013 05:51:55 GMT
Hi,

This is working as expected. Indexed documents are immutable - they may not be modified after
they are committed. (Deletions can be thought of as a separate list of deleted document identifiers,
the documents are still present in the index.)

A call to IndexWriter.UpdateDocument will issue a delete followed by an addition. The added
document will be present in a new segment once committed. There are no in-place updates.

You're always calling AddDocument which will add new documents. Any old documents will still
be present. You say that the old files are deleted when you create a new IndexWriter, this
happens (based on the KeepOnlyLastCommitDeletionPolicy which is the default deletion policy)
with files that are not associated with the latest commit. These may be uncommitted changes,
or old segments left behind after merges.

1) Check if Optimize calls Commit, or if you need to commit your changes.
2) Call UpdateDocument, instead of AddDocument, if that's the operation you're after.

// Simon

-------- Originalmeddelande --------
Från: Santanu Debnath <citytechdev5@citytechcorp.com> 
Datum:  
Till: dev@lucenenet.apache.org 
Rubrik: Update Document In existing Index File 
 
Hello 



I'm using Lucene.Net(V 2.9) in my application. I'm trying to  create an
index file and then update(add, edit and delete document) in existing index
file. 

The index file is creating successfully but when I've trying to update in
the existing index file it is not updating in existing index file instead-of
created new index file. 

It also deleting the previous index file. 



For updating in document I've written the following code. 



IndexWriter indexWriter = new IndexWriter(this._fullFeedFilePath, new
Lucene.Net.Analysis.Standard.StandardAnalyzer(),false);

Lucene.Net.Documents.Document newIndexDoc = new
Lucene.Net.Documents.Document();

ProcessPrimaryData(dataCollection, newIndexDoc);

indexWriter.AddDocument(newIndexDoc);

indexWriter.Optimize();

indexWriter.Close();



in this._fullFeedFilePath contains the directory path where the index file
exist. 

The index file is deleting at the time of IndexWriter initialization. Ie in 



IndexWriter indexWriter = new IndexWriter(this._fullFeedFilePath, new
Lucene.Net.Analysis.Standard.StandardAnalyzer(),false);



In IndexWtirer initialization, It always executing following lines and
delete old existing index file .



// Default deleter (for backwards compatibility) is

// KeepOnlyLastCommitDeleter:

deleter = new IndexFileDeleter(directory, deletionPolicy == null?new
KeepOnlyLastCommitDeletionPolicy():deletionPolicy, segmentInfos, infoStream,
docWriter); 



May you suggest what I'm doing wrong for update in the existing index file .



Please reply as soon as possible. 









Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message