Googlize your entities: NHibernate & Lucene.NET Integration

time to read 2 min | 368 words

I need to do full text searches on my entities, across many different fields, and with many different parameters. A while ago I heard about Hibernate Search(TM), and became envious. It took me about two days*, but it is (almost) here. Here is how I search my blog's posts at the moment:

using (ISession session = sessionFactory.OpenSession())

using (IFullTextSession ftSession = Search.CreateFullTextSession(session))


       IList<Post> posts = ftSession.CreateFullTextQuery<Post>("Text:NHibernate and Title:Performance")


       Assert.AreNotEqual(0, posts.Count);


And yes, I probably do have seamless integration with updating the indexes, so I wouldn't have to worry about it except for the first time. I strongly suggest that you would read the documentation above, since it is almost identical to my implementation.

Unlike most of my stuff, I am not going to release it just yet, it still needs more testing and some beating before I will let it see the light of day.

* And just to point out, no sleep, for real. I am working on caffiene and sheer inertation at the moment.