lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miles Barr <>
Subject Re: Where to find drill-down examples (source code)
Date Fri, 21 Jul 2006 14:26:19 GMT
Martin Braun wrote:

>I want to realize a drill-down Function aka "narrow search" aka "refine
>I want to have something like:
>Refine by Date:
>* 1990-2000 (30 Docs)
>* 2001-2003 (200 Docs)
>* 2004-2006 (10 Docs)
>But not only DateRanges but also for other Categories.
>What I have found in the List-Archives so far is that I have to  use
>Filters for my search.
>Does anybody knows where to find some Source Code, to get an Idea how to
>implement this?
> I think that's a useful property for a search engine, so are there any
>contributions for Lucene for that?

If you want to do a refined search I'd put the original query in a 
QueryFilter, which filters on the new search.


Query original = // saved from the last time the search was executed
QueryFilter filter = new QueryFilter(original);

QueryParser parser = ...
Searcher searcher = ...

String userQuery;
Query query = parser.parse(userQuery);

Hits hits =, filter);

Fill in the blanks with however you normally get your QueryParser and 
IndexSearcher. You could store the old query on the session, or 
somewhere else.

Then the QueryFilter will ensure you're doing a refinement, but won't 
affect the scoring in the new search.

Alternatively, since you appear to only want to refine on dates and 
categories, you might want to put them in filters so they don't affect 
the score, and leave the query as is. In which case you can use a 
RangeQuery for the dates, and a wrap a TermQuery in a QueryFilter to 
handle the categories.

If you need multiple filters you can use the ChainedFilter class.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message