The basic library can be installed via NuGet

There is a simple that should just work.

This uses the Azure Cache service to store the Lucene Indexes.

I am planning to test this on the local emulated cache to see if it works.

This is a minor update to the supplied sample (Lucene has fixed the naming conventions to confirm to C# norms):

using Lucene.Net.Analysis;
using System.IO;

using Directory = Lucene.Net.Store.Directory;
using Version = Lucene.Net.Util.Version;
using Lucene.Net.Index;
using Lucene.Net.Search;
using Lucene.Net.QueryParsers;

var fordFiesta = new Document();
fordFiesta.Add(new Field(“Id”, “1”, Field.Store.YES, Field.Index.NOT_ANALYZED));
fordFiesta.Add(new Field(“Make”, “Ford”, Field.Store.YES, Field.Index.ANALYZED));
fordFiesta.Add(new Field(“Model”, “Fiesta”, Field.Store.YES, Field.Index.ANALYZED));

var fordFocus = new Document();
fordFocus.Add(new Field(“Id”, “2”, Field.Store.YES, Field.Index.NOT_ANALYZED));
fordFocus.Add(new Field(“Make”, “Ford”, Field.Store.YES, Field.Index.ANALYZED));
fordFocus.Add(new Field(“Model”, “Focus”, Field.Store.YES, Field.Index.ANALYZED));

var vauxhallAstra = new Document();
vauxhallAstra.Add(new Field(“Id”, “3”, Field.Store.YES, Field.Index.NOT_ANALYZED));
vauxhallAstra.Add(new Field(“Make”, “Vauxhall”, Field.Store.YES, Field.Index.ANALYZED));
vauxhallAstra.Add(new Field(“Model”, “Astra”, Field.Store.YES, Field.Index.ANALYZED));

using (RAMDirectory directory = new RAMDirectory())
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);

var writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);


IndexReader indexReader = IndexReader.Open(directory, true);
using (Searcher indexSearch = new IndexSearcher(indexReader))
var queryParser = new QueryParser(Version.LUCENE_30, “Make”, analyzer);
var query = queryParser.Parse(“Ford”);

Console.WriteLine(“Searching for: ” + query.ToString());
TopDocs resultDocs = indexSearch.Search(query, indexReader.MaxDoc);

Console.WriteLine(“Results Found: ” + resultDocs.TotalHits);

var hits = resultDocs.ScoreDocs;
foreach (var hit in hits)
var documentFromSearcher = indexSearch.Doc(hit.Doc);
Console.WriteLine(documentFromSearcher.Get(“Make”) + ” ” + documentFromSearcher.Get(“Model”));


I have a sample app that uses the Azure Cache As A Service version:

You need to supply your own cache service id and authentication string.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s