FindAll function in Lucene.net

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

If the user doesn't enter anything in the two fields and doesn't submit the page, how do I make Lucene.Net return all the books from my index regardless of the BookAuthor and BookDescription field values?

Thank!

0


source to share


2 answers


I'm not sure if this is the correct way, but you can add another invalid term to the index (say BookIsPublished) with a default value and if the user does not return a search request for all matching items in the BookIsPublished persistent field.



0


source


the correct way to do it is to use MatchAllDocsQuery:



http://lucene.apache.org/java/2_9_4/api/core/org/apache/lucene/search/MatchAllDocsQuery.html

+3


source







All Articles