Search code examples
lucene.netnhibernate-search

How do I disable some entities based on a few properties in NHibernate Search?


Im still pretty new to NHibernate.Search so please bear with me if this is stupid question :)

Say, I have indexed some entities of type BlogPost, which has a property called IsDeleted. If IsDeleted is set to true, I don't want my queries to show this particular blogpost.

Is this possible? And if it is - How? :P

Thanks in advance - cwap


Solution

  • Found the solution myself. I added the [Field(Index.Tokenized, Store = Store.Yes)]-attribute to the IsDeleted property, and added this clause to any query inbound:

    string q = "(" + userQuery + ") AND IsDeleted:False";
    

    I knew it was something simple :)