Lucene Filter and Query Concept

Home / Uncategorized / Lucene Filter and Query Concept

I am working on a search project in Java and I’m using Lucene. I want to filter my final search results with a query from the user (e.g. "x" AND "Y") as a feature of advanced search. My search query consists of queries on different parts of a news and it’s working correctly but my filter doesn’t work properly So I’m using following code:leadFilter = new QueryWrapperFilter(new QueryParser(LUCENE_VERSION, INDEX_FIELD_LEAD, analyzer).parse(advanceFilter));
titleFilter = new QueryWrapperFilter(new QueryParser(LUCENE_VERSION, INDEX_FIELD_TITLE, analyzer).parse(advanceFilter));

booleanFilter.add(leadFilter, Occur.SHOULD);
booleanFilter.add(titleFilter, Occur.SHOULD);

topDocs =, booleanFilter,query.getLimit());

maybe I have not understood the concept of "Filter" correctly. So please correct me or propose another way to filter results after a search by Lucene.

Thanks in advance


Read more

Leave a Reply

Your email address will not be published. Required fields are marked *