How to get SimpleLucene.Net to work with Azure

We are using SimpleLucene throughout our application for searching. Everything works fine. We upload our application to azure and it works fine, however, every time I do any changes and have to re-upload to Azure I have to re-create index to make sure it is up-to-date. I want to move my Azure index to Blob storage on azure, however I dont know how to get Azure Lucene Directory working with SimpleLucene. Sample code would be appreciated.

I am building index like this.

var path = @"my path to the index";
var indexWriter = new SimpleLucene.Impl.DirectoryIndexWriter(new System.IO.DirectoryInfo(path), true);
var definitions = GetDefinitions().ToList();

using (var indexService = new SimpleLucene.Impl.IndexService(indexWriter))
{
     try
     {
         indexService.IndexEntities(definitions, new DefinitionsIndexDefinition());
     }
     catch { }
}

How can I create indexWriter from Azure blob storage? I know there is AzureDirectory dll that I can use but it doesn't work with SimpleLucene

Answers


I would say that Simple Lucene may not be a good option to use with Windows Azure because I am not sure if it has code to store the index on Windows Azure Blob Storage. Are you sure it can save to index on Windows Azure Blob storage?

I have used Lucene.NET for Windows Azure, which you can use to store index on Windows Azure Blob storage directly by setting Azure Blob Storage

Step 1: Configure your Azure Blob Storage

<configuration>
  <appSettings>
    <!-- azure SETTINGS -->
    <add key="BlobStorageEndpoint" value="http://YOURACCOUNT.blob.core.windows.net"/>
    <add key="AccountName" value="YOURACCOUNTNAME"/>
    <add key="AccountSharedKey" value="YOURACCOUNTKEY"/>
  </appSettings>
</configuration>

Step 2: Use IndexWriter to store index on Azure Blob Storage:

AzureDirectory azureDirectory = new AzureDirectory("TestCatalog");
IndexWriter indexWriter = new IndexWriter(azureDirectory, new StandardAnalyzer(), true);
Document doc = new Document();
doc.Add(new Field("id", DateTime.Now.ToFileTimeUtc().ToString(), Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO));
doc.Add(new Field("Title", “this is my title”, Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO));
doc.Add(new Field("Body", “This is my body”, Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO));
indexWriter.AddDocument(doc);
indexWriter.Close();

So if you decide to use Lucene.net for Windows Azure that would be the comparatively easier and best course of action.


Need Your Help

Rails Associations Technique

ruby-on-rails ruby activerecord ruby-on-rails-4 rails-activerecord

I have a User model in which their are two booleans for admin and manager statuses, each manager can have only one job created, and each job can have many managers. I made a model for the jobs whic...

PHP create table error 1064

php mysql syntax-error create-table

I am trying to create a table in mySQL. This is my php page below, when I run the page there are no errors but the table is not in mySQL and when I test the code in mySQL I'm getting the error