Two ways to work through the Hits object getting docids are:

Hits hits = ...
int hitCount = hits.length();
for (int i=0;i<hitCount;i++) {
   int docId = hits.id[i] ;
   ...
}

or

Iterator hitIterator = hits.iterator() ;
while (hitIterator.hasNext()) {
    Hit hit = (Hit) hitIterator.next() ;
    int docId = hit.getId() ;
}

but check out
http://lucene.apache.org/java/2_3_0/api/org/apache/lucene/search/Hits.html
as this is just code typed into a mail program!

Regards,

Kent

On Fri, Feb 22, 2008 at 4:17 PM, sumittyagi <[EMAIL PROTECTED]> wrote:
>
>  hi, is there any way to retrieve the doc ids from HITS, Please advise me
>  regarding this , i am new to lucene and programming.
>  --
>  View this message in context: 
> http://www.nabble.com/How-to-get-the-doc-ID-from-HITS-tp15627959p15627959.html
>  Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to