Skip to content

robrich/LuceneCloudDirectory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LuceneCloudDirectory

This project is a Lucene.net Directory provider that stores the content on a cloud provider and caches content in a local directory. You use the CachedDirectory as you would Lucene's FSDirectory. This project is a fork of AzureDirectory with support for other cloud providers.

Supported Cloud Providers:

  • Azure
  • Amazon

There is also a CachedFolderProvider that allows you to flex the CachedDirectory without needing to sign up for an account on one of these cloud providers.

Example Use

Open up any of the Test projects to see it in use.

  1. Install Lucene.net NuGet package

  2. Reference the built output from your chosen cloud provider project (e.g. /AmazonDirectory/bin/Debug/Lucene.Net.Store.Cloud.Amazon.dll)

  3. Instantiate the CloudProvider (e.g. AmazonCloudProvider)

     string amazonKey = ConfigurationManager.AppSettings["AmazonKey"];
     string amazonSecret = ConfigurationManager.AppSettings["AmazonSecret"];
     string bucket = ConfigurationManager.AppSettings["AmazonBucket"];
     string region = ConfigurationManager.AppSettings["AmazonRegion"];
     
     ICloudProvider provider = new AmazonCloudProvider( amazonKey, amazonSecret, bucket, region );
    
  4. Instantiate the CachedDirectory

     using (CachedDirectory cachedDirectory = new CachedDirectory(provider)) {
    
  5. Use Lucene.net as you normally would

     	using (StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_30)) {
     		using (IndexWriter indexWriter = GetIndexWriter(cachedDirectory, analyzer)) {
     			Document doc = new Document();
     			doc.Add(new Field("id", DateTime.Now.ToFileTimeUtc().ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));
     			doc.Add(new Field("Title", "the title", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));
     			doc.Add(new Field("Body", "this is a document body", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));
     			indexWriter.AddDocument(doc);
     		}
     	}
    
     	using (IndexSearcher searcher = new IndexSearcher(cachedDirectory)) {
     		SearchForPhrase(searcher, "title");
     		SearchForPhrase(searcher, "body");
     	}
     }
    

License

AzureDirectory is released as MS-PL Lucene.net is released as Apache 2.0 This project is released as Apache 2.0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published