1

I want to use lucene.net to do some searching for data. I read about nhibernate search that combines lucene.net and nhibernate to do searching.

However I use fluent nhibernate and I like to use linq. I don't think using fluent nhibernate will be a problem but I can't seem to find any examples that uses linq with nhiberante search.

Can I use linq?

chobo2
  • 83,322
  • 195
  • 530
  • 832

1 Answers1

0

You can use both NHibernate.Search and FluentNHibernate simultaneously, you just need to hookup the NHibernate.Search listeners when creating the ISessionFactory.

Personal opinions ahead!

I dislike the use of linq to use fulltext search capabilities, it's just an attempt to hide the real and usually powerful interface behind a dumbed down api, and there's usually something that goes wrong or gets lost along the way. (An example is linq-to-sql with a simple where user.Alias == "sisve", which automagically translates to the sql WHERE Alias = 'sisve'. It takes some detailed knowledge to understand that what's a case-sensitive comparison in C# becomes a case-insensitive comparison in a standard installation of SQL Server.)

Both NHibernate and Lucene are powerful libraries, but I would say to keep them separate. Build the Lucene index yourself (you can do this using custom listeners, just like the NHibernate.Search listeners), and query it yourself. This gives you a better insight in how both systems work, and you can more easily build on this implementing a better search (did you mean, facets, custom boosting, ...)

sisve
  • 19,501
  • 3
  • 53
  • 95