-
Notifications
You must be signed in to change notification settings - Fork 10
Home
pardahlman edited this page Sep 27, 2012
·
6 revisions
A Fluent NHibernate.Search Attributes-Less mapping interface for NHibernate provider implementation of Lucene.NET.
- NHibernate : 3.2.0.4000
- NHibernate.Search : Compiled from this repository against NH 3.2 and Lucene.NET 2.9.4.1
- Lucene.NET : 2.9.4.1
http://blog.sb2.fr/post/2010/03/05/Introducing-FluentNhibernateSearch-Mapping-Interface.aspx
http://blog.sb2.fr/post/2010/03/08/FluentNHibernarteSearch-03-Beta-Released-Now-Support-Fluent-XML-Less-Configuration.aspx
http://blog.sb2.fr/post/2010/03/07/FluentNHibernarteSearch-02-Beta-Released.aspx
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();
}
}
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();
}
}
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();
}
}
public class LibrarySearchMapping : SearchMapping
{
protected override void Configure()
{
AddAssembly(Assembly.GetExecutingAssembly());
}
}
Configuration nhcfg = FluentSearch.Configure()
.DefaultAnalyzer().Standard()
.DirectoryProvider().FSDirectory()
.IndexBase("~/Index")
.IndexingStrategy().Event()
.MappingClass<LibrarySearchMapping>()
.BuildConfiguration();
Configuration config = Fluently
.Configure()
.Database(SQLiteConfiguration.Standard.InMemory())
.ExposeConfiguration(cfg =>
{
FluentSearch.Configure(cfg)
.DefaultAnalyzer().Standard()
.DirectoryProvider().RAMDirectory()
.IndexingStrategy().Event()
.MappingClass<SearchMap>();
cfg.SetListeners(ListenerType.PostInsert, new[] {new FullTextIndexEventListener()});
cfg.SetListeners(ListenerType.PostUpdate, new[] {new FullTextIndexEventListener()});
cfg.SetListeners(ListenerType.PostDelete, new[] {new FullTextIndexEventListener()});
cfg.SetListener(ListenerType.PostCollectionRecreate, new FullTextIndexCollectionEventListener());
cfg.SetListener(ListenerType.PostCollectionRemove, new FullTextIndexCollectionEventListener());
cfg.SetListener(ListenerType.PostCollectionUpdate, new FullTextIndexCollectionEventListener());
})
.BuildConfiguration();