web 2.0

Introducing FluentNhibernate.Search Mapping Interface

Coming back for a long time…

I announce today a new project i’ve hosted on CodePlex about NHibernate.Search, a Lucene.NET provider  implementation for NHibernate which is a part of the NHibernate Contrib project.

fluentnhs

Actually NHibernate.Search is attributes based mapping.

   1: [Indexed]
   2: public class Book
   3: {
   4:     [DocumentId]
   5:     public Guid BookId { get; set; }
   6:  
   7:     [Field(Index=Index.Tokenized, Name="Title", Store=Store.Yes)]
   8:     public string Title { get; set; }
   9:  
  10:     [Field(Index = Index.Tokenized, Name = "Description", Store = Store.Yes)]
  11:     public string Description { get; set; }
  12: }

In my recent projects I needed to keep my domain entites true POCO and persistant ignorant.

Since there was no Fluent inteface to map Lucene.NET documents without attributes outside domain entities, I decided to start this project which I hope should make us feel better :)

FluentNHibernate.Search mapping is quite equivalent to FluentNHibernate for NHibernate XML-Less entity mapping initialy developped by Jeremy Miller.

 

Mapping Lucene.NET documents are now very simple, attribute-less, here is a sample :

   1: public class Book
   2: {
   3:     public Guid BookId { get; set; }
   4:     public string Title { get; set; }
   5:     public string Description { get; set; }
   6: }

Woow, that’s clean :)

And here is the mapping class :

   1: public class BookSearchMap : DocumentMap<Book>
   2: {
   3:     public BookSearchMap()
   4:     {
   5:         Id(p => p.BookId).Field("BookId").Bridge().Guid();
   6:         Name("Book");
   7:         Boost(500);
   8:         Analyzer<StandardAnalyzer>();
   9:  
  10:         Map(x => x.Title)
  11:             .Analyzer<StandardAnalyzer>()
  12:             .Boost(500);
  13:  
  14:         Map(x => x.Description)
  15:             .Boost(500)
  16:             .Name("Description")
  17:             .Store().Yes()
  18:             .Index().Tokenized();
  19:     }
  20: }

Pretty nice isn’t it ? :)

 

FluentNHibernate.Search is still in developpement but I hope I will release a stable version soon.

Until a stable version be released you can check the current source code at CodePlex and give feedbacks !



Views(1805)

kick it on DotNetKicks.com

Share/Save/Bookmark Subscribe

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

C# | NHibernate | Lucene.NET

Comments

Technorati Profile