lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: categorisation
Date Thu, 08 Feb 2007 18:37:05 GMT

On Feb 8, 2007, at 12:36 PM, Kainth, Sachin wrote:

> Chris has given an example of how to perform categorisation of  
> lucene searches:
>
> String[] mfgs = ...;
>   String query = "+category:cameras +price:[0 to 10]";
>   Query q = QueryParser.parse(query);
>   Hits results = searcher.search(q, mySort)
>   BitSet all = (new QueryFilter(q)).bits(reader)
>   int[] mfg_counts = new int[mfgs.length];
>   for i in (0 to mfgs.length) {
>      BitSet these = (new QueryFilter(new TermQuery("mfg",mfgs 
> [i]))).bits(reader);
>      these.and(all)
>      mfg_counts[i] = these.cardinality();
>   }
>
> What I don't understand though is what this line does:
>
> BitSet all = (new QueryFilter(q)).bits(reader)
>
> Anyone have any ideas?

"all" is a BitSet lit up for the documents that matched "query".   
"these" (the BitSet for a particular category) is .anded with "all"  
to get the counts _left over_ for each category given "query".

Make sense?

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message