Thanks, Thats okay for short index, But if index have millions of records or GB's data then it will get slow . So what is better ?
On 5/30/07, Erich Eichinger <[EMAIL PROTECTED]> wrote:
hi, I guess it doesn't work without any iteration. Another option coming to my mind: If the list of possible classnames isn't too long, you could do (pseudocode) Hashtable resultCount = new Hashtable(); foreach( string classname in possibleClassNames ) { resultlist = index.SearchFor("Name:Menaria AND Class:"+classname) resultCount[classname] = resultlist.Count; } cheers, Erich > -----Original Message----- > From: Michael Mitiaguin [mailto:[EMAIL PROTECTED] > Sent: Wednesday, May 30, 2007 9:33 AM > To: [EMAIL PROTECTED] > Subject: Re: Get all unique values of specific field > > Laxmilal , > > What's the problem with a hit list iteration ( it should be > very fast ) ? > I am not sure about equivalent of SQL "distinct" in Lucene. > You didn't describe whether you index ( and plus store ) all fields. > Effectively you may just store a primary key ( let's say > incremental int id for the sake of example , though you > table doesn't look normalised , it doesn't really matter in > our case ) which will be stored not indexed , the rest > may be indexed as ( Name + Address + Class ...) or as > separate fields if you need to and either stored or not stored. > Having applied search "Name:Menaria" ( and having written > all this I realised that you still need to iterate a hit list > but let me finish > :) ) you may form a string with coma delimited IDs and then > > "select distinct class from mytable where where id in "(" + > formedstring + ") " > > Surely if you store everything in Lucene index , there is no > need to query database and you may use collections for > picking up distinct "Class" values , but my understanding > you still need to iterate through Hits > > Regards > Michael > > On 5/30/07, Laxmilal Menaria <[EMAIL PROTECTED]> wrote: > > Hello everyone, > > > > I have created a Lucene Index of Students Database, this > database have > > 5 fields i.e. Name, Address, Class, PhoneNo and ScholarNo. > > Now I have opened Searcher and query "Name:Menaria" , Its > return 100 > > results. Now I wants the All unique "Class" names which is > return in > > Hits objects, How can I get unique Class list without using Loop. > > > > Please suggest me.. > > > > -- > > Thanks, > > Laxmilal menaria > > > > http://www.minalyzer.com/ > > http://www.chambal.com/ > > >
-- Thanks, Laxmilal menaria http://www.minalyzer.com/ http://www.chambal.com/