tags:

views:

96

answers:

3

Hi,

I have two fields on my web page ie: BookAuthor and BookDescription.On submit,the page searches against lucene index using the given search criteria.

If the user does not type in anything in the two fields and submits the page, how do make Lucene.Net return all the books from my index irrespective of BookAuthor and BookDescription field values?

Thanks!

+1  A: 

The common solution here is to add another field to every document in your index. It's a fake field, like "ALL_RECORDS", that contains some dummy value, like "x". Lucene won't take an empty query, so if a user tries to perform one, your application replaces it with a query like "ALL_RECORDS:x", which returns every record.

erickson
A: 

Beautiful..!thanks for your inputs!!

A: 

Use a MatchAllDocsQuery.

Bas Leijdekkers