views:

66

answers:

1

I'm building an ASP.NET MVC site where I want to use Lucene.Net for full-text search. My site will be divided into certain categories, and I want to allow users to search inside a specific category or inside all categories.

To accomplish this, I plan to create a term in all documents in my index that contains the name of the category that they're in. When querying the index, I would need to execute a query that contains a WHERE clause if the user only wants results from one category.

Does such WHERE clause functionality exist in Lucene/Lucene.Net?

+3  A: 

How do I restrict searches to only return results from a limited subset of documents in the index (e.g. for privacy reasons)? What is the best way to approach this?

Leniel Macaferi
Thanks for the link. The FAQ there says: "Just before calling `IndexSearcher.search()` add a clause to the query to exclude documents in categories not permitted for this search." How do I add a clause to the query?
Maxim Zaslavsky
Take a look here to see how to use the QueryFilter class - http://stackoverflow.com/questions/1307782/lucene-net-combine-multiple-filters-and-no-search-terms
Leniel Macaferi
To implement a custom filter: http://stackoverflow.com/questions/1079934/how-do-you-implement-a-custom-filter-with-lucene-net
Leniel Macaferi