We have seen integration of lucene in the last article. This article we will look into implementation of lucene indexes using is a open source project created in java that helps integration of lucene in .net.

Need : 

If you application requires a full text search implemented. Lucene is an exclusive library that can help in this. It is pretty simple to implement and is also open source. It performs  efficient indexing and searching operation on large number of documents.

Implementation :

Lucene can also be used to search through entity framework. code is available on github at This code can be complied and used. You can also add lucene nugget packages to the code using Install-Package Lucene.Net.

Before performing indexing let us look into the different concepts and terms used in lucene:

Field: This a dictionary or hashtable consisting of name and value pair. The values of a field can be stored, indexed and analyzed.

Document: Lucene consist of documents. This document consists sequence of fields.

Directory: Lucene store the indexes here.

IndexWriter: This helps to create lucene indexes and analyse them and store the documents to the indexes.

Analyzer: This helps in retrieving the text or keys from the dictionary.

IndexReader: This help in easy search of index documents.

Now let us look into the indexing part of lucene:

The components that are required for lucene indexing are directory, analyser, Indexwiter, document and field.

public class Indexer 

   Directory directory = FSDirectory.Open(“path of directory to be analyzed”);
   Analyzer analyzer = new   StandardAnalyzer(LuceneUtil.Version.LUCENE_29);
   IndexWriter writer = new IndexWriter(directory, analyzer ,true, IndexWriter.MaxFieldLength.UNLIMITED);
   Document doc = new Document();
   doc.Add(new Field(“fieldName”,


The above code will help you index the application for full text search. If you want analyze all the documents within a directory you will need to loop through all the documents within the directory to add it to the index.


Michael Patterson sat down with the CEO of Boston Byte, Mustapha Shaikh to discuss the significance and rapid digitization of the healthcar...