lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Braun <mbr...@uni-hd.de>
Subject Re: About the use of HitCollector
Date Mon, 07 Aug 2006 10:52:15 GMT
hi andy,
> How can I  use HitCollector to iterate over every returned document?

You have to override the function collect for the HitCollector class and
then store the retrieved Data in an array or map.

Here is just a source-code scratch (is = IndexSearcher)

 	        is.search(query, null, new HitCollector(){
 	        		public void collect(int docID, float score)
                    	            {
					Document doc = is.doc(docID);
                    	                titles[docID] = doc.get("title");
                    	            }
           	        });


hth,
martin

---------------------------------------------------------------------
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