PROJECT MOVED TO GITHUB


Project Description
A Fluent NHibernate.Search Attributes-Less mapping interface for NHibernate provider implementation of Lucene.NET.

Current source code works against the following dependencies :

NHibernate : 2.1.2.4000
NHibernate.Search : Compiled from trunk against Lucene.NET 2.9.1.2
Lucene.NET : 2.9.1.2

Project Announcement
http://blog.sb2.fr/post/2010/03/05/Introducing-FluentNhibernateSearch-Mapping-Interface.aspx

0.3 Beta Announcement
http://blog.sb2.fr/post/2010/03/08/FluentNHibernarteSearch-03-Beta-Released-Now-Support-Fluent-XML-Less-Configuration.aspx

0.2 Beta Announcement
http://blog.sb2.fr/post/2010/03/07/FluentNHibernarteSearch-02-Beta-Released.aspx

Simple Mapping Sample

    public class BookSearchMap : DocumentMap<Book>
    {
        public BookSearchMap()
        {
            Id(p => p.BookId).Bridge().Guid();
            Name("Book");

            Map(x => x.Title)
                .Store().Yes()
                .Index().Tokenized();
            Map(x => x.Description)
                .Store().Yes()
                .Index().Tokenized();
        }
    }

Embedded Mapping Sample

    public class AuthorSearchMap : DocumentMap<Author>
    {
        public AuthorSearchMap()
        {
            Id(p => p.AuthorId).Bridge().Guid();
            Name("Author");

            Map(x => x.Name)
                .Store().Yes()
                .Index().Tokenized();

            Embedded(x => x.Books).AsCollection();
        }
    }

Getting Started
  • Create Entity Mappings Classes :

    public class AuthorSearchMap : DocumentMap<Author>
    {
        public AuthorSearchMap()
        {
            Id(p => p.AuthorId).Bridge().Guid();
            Name("Author");

            Map(x => x.Name)
                .Store().Yes()
                .Index().Tokenized();

            Embedded(x => x.Books).AsCollection();
        }
    }
  • Create NHibernate.Search Mapping Factory

    public class LibrarySearchMapping : SearchMapping
    {
        public LibrarySearchMapping()
        {
            AddAssembly(Assembly.GetExecutingAssembly());

            AssertIsValid();
        }
    }
  • Configure NHibernate.Search Fluently

            Configuration nhcfg = FluentSearch.Configure()
                .DefaultAnalyzer().Standard()
                .DirectoryProvider().FSDirectory()
                .IndexBase("~/Index")
                .IndexingStrategy().Event()
                .MappingClass<LibrarySearchMapping>()
                .BuildConfiguration();
  • Configure NHibernate.Search Fluently atop FluentNHibernate

    Fluently.Configure()
        .Database(SQLiteConfiguration.Standard.InMemory())
        .Search(s => s.DefaultAnalyzer().Standard()
                                 .DirectoryProvider().RAMDirectory()
                                 .IndexingStrategy().Event()
                                 .MappingClass<LibrarySearchMapping>())
        .BuildConfiguration()

Last edited Jun 21, 2010 at 7:36 AM by inetux, version 15