serach the archives for "faceted searching" and "category counts" and you should find lots of discussions on this topic.
: Date: Tue, 21 Nov 2006 20:30:22 +0530 : From: Bhavin Pandya <[EMAIL PROTECTED]> : Reply-To: java-user@lucene.apache.org, Bhavin Pandya <[EMAIL PROTECTED]> : To: java-user@lucene.apache.org : Subject: Re: is there any way to find unique records ? : : Hi Erick, : : > If your asking for a list of all the unique values for a particular field, : > see TermDocs and/or TermEnum which will allow you to look at, say, all the : > values stored for some field. A trick here is to seek (new Term("field", : > ""));. By putting nothing in the value, you effectively enumerate them : > all, : > something that I didn't find obvious : : I think your above solution is very near to what i am looking for , : But little bit different way... : here is what i am planning to do... : : Suppose my index has four fields "product-title" , "product-desc" , : "category" and "FLAG" ( Fieldname FLAG has value "true" for each n every : doc in index ...just added for iteration purpose ) : : At search time.. . : query = +(product-title:nokia) +(product-desc:nokia) : Hits hits = searcher.search(query); : I want to fetch unique "category" from above hits object... : : But i dont want to iterate through Hits object.... : : Now As per your suggestions, I can do something like this... : TermEnum enum = termDocs(new Term("FLAG","true") : But it will return enumeration of all the document which is in index...But i : want enumeration of all the document which is relevant to "nokia"... : How to . . ? : : Thanks : - Bhavin pandya : : : ----- Original Message ----- : From: "Erick Erickson" <[EMAIL PROTECTED]> : To: <java-user@lucene.apache.org>; "Bhavin Pandya" <[EMAIL PROTECTED]> : Sent: Tuesday, November 21, 2006 7:01 PM : Subject: Re: is there any way to find unique records ? : : : > I don't think I understand what "only unique records from a single field" : > means. If it's a unique value in a filed, there'll only be one document : > in : > the hits object and there's no cost to iterating, so I doubt that's what : > you : > mean. : > : > If your asking for a list of all the unique values for a particular field, : > see TermDocs and/or TermEnum which will allow you to look at, say, all the : > values stored for some field. A trick here is to seek (new Term("field", : > ""));. By putting nothing in the value, you effectively enumerate them : > all, : > something that I didn't find obvious. : > : > If neither of these are close to the mark, perhaps you could provide more : > detail. : > : > Best : > Erick : > : > On 11/21/06, Bhavin Pandya <[EMAIL PROTECTED]> wrote: : >> : >> Hi, : >> In lucene, is there any way to find only unique records from a single : >> field ..? : >> : >> otherwise unnecessary i have to itereate through Hits and find out : >> unique... : >> : >> plz help.. : >> : >> - Bhavin pandya : >> : > : : : --------------------------------------------------------------------- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]