I have inherited some code that uses Simple Lucene. I know very little about Simple Lucene. Right now, the code relies on the IndexService to index entities. The following code is used:
using (var indexService = GetIndexService())
{
indexService.IndexEntities(cachedResults, p =>
{
var document = new Document();
document.Add(new Field("Name", p.Name, Field.Store.YES, Field.Index.NOT_ANALYZED));
document.Add(new Field("ID", p.ID, Field.Store.YES, Field.Index.NOT_ANALYZED));
document.Add(new Field("Description", p.Description, Field.Store.YES, Field.Index.NOT_ANALYZED));
return document;
});
}
GetIndexService returns a SimpleLucene.Impl.DirectorySerivce instance. This approach was used to store the index on a local machine. However, now I need to move this to a Windows Azure Storage blob. In an attempt to do that, I’m relying on the library found at: https://github.com/richorama/AzureDirectory.
The example shown here returns a Lucene.Net.Index.IndexWriter. I have no idea how to use this object with the approach that’s there. The types seem entirely incompatible. All I wanted to do was use a different storage location for the index files. Is there a way to do this? If so, how. I’m completely up a creek here. Thanks!
It appears that
IndexEntitieslooks like this:Basically, it opens an IndexWriter, iterates through a list of entities, converts them to documents, and adds them to the index through the writer, and returns a count.
You indicate that you are returned an IndexWriter from the package, so you don’t need to worry about creating one. You are creating a document, so no mapping is necessary (the converter could make some changes to a document passed in, I suppose, but probably not), and you are just making one, so iterating or counting aren’t really nercessary. All that’s left is adding the Document, through
IndexWriter.addDocument(Document)