O'Reilly logo

Instant Lucene.NET by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating a document's search data in an index (Become an expert)

If a document that has previously been indexed is updated and you want the changes to be reflected in future search results, you will need to reindex that document to make the changes available.

How to do it…

Updating of document index data is performed by the UpdateDocument method of an IndexWriter object. UpdateDocument takes two parameters: a term to look up the document to be replaced and a Document instance used to replace the existing document.

The following example shows how to update a document. It creates an index containing five documents, uses a search to find one of the documents (containing four), creates a new document object with new field values/content, and instructs ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required