lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dharmalingam Ganesan" <dgane...@fc-md.umd.edu>
Subject RE: How to get the doc ID from HITS
Date Fri, 22 Feb 2008 21:10:47 GMT
It should be hits.id(i), not hits.id[i]. Note id is a method not an
array.

-----Original Message-----
From: sumittyagi [mailto:ping.sumit@gmail.com] 
Sent: Friday, February 22, 2008 4:06 PM
To: java-user@lucene.apache.org
Subject: Re: How to get the doc ID from HITS


here is my code, i am just starting, so having little bit of trouble in
starting, i am just trying to access some values and then want to print
it
to get started..
here is my code


package db;
import java.io.*;
import java.util.*;
import java.lang.*;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.Hit;

public class comm{
	public static void main(String[] args)
	{
		System.out.println("hi");
	
	
Hits hits;
int hitCount = hits.length();
for (int i=0;i<hitCount;i++) {
   int docId = hits.id[i] ;
  
} 
}
}

and the errors i am getting are

C:\Documents and Settings\Sumit\Desktop>javac db/comm.java
db/comm.java:20: cannot find symbol
symbol  : variable id
location: class org.apache.lucene.search.Hits
   int docId = hits.id[i] ;
                   ^
1 error


any advice please....





sumittyagi wrote:
> 
> thanks for replying
> it may be a silly question but what do in the code
> 
> Hits hits = ...
> int hitCount = hits.length();
> for (int i=0;i<hitCount;i++) {
>    int docId = hits.id[i] ;
>    ...
> }
> 
> 
> what do i need to type for "....." in the 1st line, which is "Hits
hits =
> ..."
> 
> 
> Kent Fitch wrote:
>> 
>> 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.ht
ml
>> as this is just code typed into a mail program!
>> 
>> Regards,
>> 
>> Kent
>> 
>> On Fri, Feb 22, 2008 at 4:17 PM, sumittyagi <ping.sumit@gmail.com>
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-tp15627959p1562795
9.html
>>>  Sent from the Lucene - Java Users mailing list archive at
Nabble.com.
>>>
>>>
>>>
---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>>  For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/How-to-get-the-doc-ID-from-HITS-tp15627959p1564141
0.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


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