NHProf in the real world: NHibernate Search integration

time to read 2 min | 276 words

I had a problem in one of my applications, a Lucene search was returning more results than I wanted it to, and I wasn’t sure what was going on.


I pre marked the problematic line, but at the time, I had no idea why it is returning me all those extra results that had nothing to do with my queries. But since NH Prof gave me the full Lucene query text, I could take this and plug this into Luke.


Luke is the preferred tool to working with Lucene indexes, and running the query allowed me to play around and figure out what my problem was:


I was specifying that everything that is active MUST be returned, and everything that matches the query should be returned. Obviously, anything that is active (regardless of the rest of the query), must be returned.

In effect, this is similar to this SQL query:

select * from Entries
where IsActive = 1 or ( ... )

Once I figured that one out, it was pretty easy to fix the query to use MUST_NOT IsActive == False. But it would have been much harder without NH Prof.