NH Prof New FeatureNHibernate Search Integration

time to read 3 min | 460 words

Well, I was demoing how easy it is to add new features to NH Prof in a user group in JAOO today, and tomorrow I am doing my OR/M += 2 talk. Part of the things that I want to show is NHibernate Search, but the demo doesn’t really work unless I can point to NH Prof and show what is going on there.

I now consider output results to the console to be so 2005.

Here is the code that I am using for this post:

using (var s = factory.OpenSession())
    var posts = NHibernate.Search.Search.CreateFullTextSession(s)
        .CreateFullTextQuery<Post>("Title:NHibernate User.Name:ayende")

        .CreateFullTextQuery<Post>("Title:NHibernate User.Name:ayende")

    foreach (var post in posts)

I had to make a small modification to NHibernate Search, to output the right information (which means that you can make this work with r1044 or up), but here is the result:


Notice that you can get not only the actual Lucene query text, but you also get the query duration and the number of returned results. The next query is NHibernate Search actually hitting the database to load the managed entities, after hitting the Lucene index to perform the actual search.

We can also generate some warnings on top of Lucene! As you can see here, we detect unbounded queries:


If you do specify a maximum number of entities to return, we are going to reflect that in the query directly:


We can also tell you if your Lucene index is out of date with respect to the database:


Sweet, and is currently warming up in the oven, build 488 should have it.

More posts in "NH Prof New Feature" series:

  1. (09 Dec 2010) Alert on bad ‘like’ query
  2. (10 Dec 2009) Filter static files
  3. (16 Nov 2009) Exporting Reports
  4. (08 Oct 2009) NHibernate Search Integration
  5. (19 Aug 2009) Multiple Session Factory Support
  6. (07 Aug 2009) Diffing Sessions
  7. (06 Aug 2009) Capturing DDL
  8. (05 Aug 2009) Detect Cross Thread Session Usage
  9. (22 May 2009) Detecting 2nd cache collection loads
  10. (15 May 2009) Error Detection
  11. (12 May 2009) Queries by Url
  12. (04 Feb 2009) View Query Results
  13. (18 Jan 2009) Superfluous <many-to-one> update
  14. (18 Jan 2009) URL tracking
  15. (10 Jan 2009) Detecting distributed transactions (System.Transactions)
  16. (06 Jan 2009) The Query Cache
  17. (05 Jan 2009) Query Duration
  18. (24 Dec 2008) Unbounded result sets
  19. (24 Dec 2008) Row Counts