Martin Braun wrote:
I want to realize a drill-down Function aka "narrow search" aka "refine
search".
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.
http://lucene.apache.org/java/docs/api/org/apache/lucene/search/QueryFilter.html
e.g.
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 = searcher.search(query, 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.
Miles
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]