Quantcast
Channel: fnhsearch Wiki Rss Feed
Viewing all articles
Browse latest Browse all 13

Updated Wiki: Home

$
0
0
Project Description
A Fluent NHibernate.Search 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.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 SearchMapping : SearchMappingProvider
    {
        public SearchMapping()
        {
            AddAssembly(Assembly.GetExecutingAssembly());

            AssertIsValid();
        }
    }

  • Configure Web.config or App.config (This configuration will be replaced with a Fluent way in a future release)

<configuration>
  <configSections>
        <section name="nhs-configuration" type="NHibernate.Search.Cfg.ConfigurationSectionHandler, NHibernate.Search"/>
  </configSections>
  <nhs-configuration xmlns="urn:nhs-configuration-1.0">
    <search-factory>
      <property name="hibernate.search.default.directory_provider">NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search</property>
      <property name="hibernate.search.default.indexBase">~/Index</property>
      <property name="hibernate.search.indexing_strategy">event</property>
      <property name="hibernate.search.analyzer">Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net</property>
      <property name="hibernate.search.mapping">MyAssembly.Mappings.SearchMapping, MyAssembly</property>
    </search-factory>
  </nhs-configuration>
</configuration>

Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>