You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by sumittyagi <pi...@gmail.com> on 2008/02/22 06:17:36 UTC
How to get the doc ID from HITS
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: How to get the doc ID from HITS
Posted by Gauri Shankar <gs...@gmail.com>.
You should call Hits.id(n) for getting the docId of the nth document.
On Fri, Feb 22, 2008 at 10:47 AM, sumittyagi <pi...@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-tp15627959p15627959.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
>
>
--
Regards,
Gauri Shankar
RE: How to get the doc ID from HITS
Posted by Dharmalingam Ganesan <dg...@fc-md.umd.edu>.
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 <pi...@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
Re: How to get the doc ID from HITS
Posted by ZaeX <za...@gmail.com>.
Hi,
You should get the `Hits' from `IndexSearcher.search(...)'
You could refer to the example code in the Lucene source package, or have a
look at the book `Lucene in Action'
2008/2/23, sumittyagi <pi...@gmail.com>:
>
>
> 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.html
> >> as this is just code typed into a mail program!
> >>
> >> Regards,
> >>
> >> Kent
> >>
> >> On Fri, Feb 22, 2008 at 4:17 PM, sumittyagi <pi...@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-tp15627959p15627959.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-tp15627959p15641410.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
>
>
Re: How to get the doc ID from HITS
Posted by sumittyagi <pi...@gmail.com>.
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.html
>> as this is just code typed into a mail program!
>>
>> Regards,
>>
>> Kent
>>
>> On Fri, Feb 22, 2008 at 4:17 PM, sumittyagi <pi...@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-tp15627959p15627959.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-tp15627959p15641410.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
Re: How to get the doc ID from HITS
Posted by sumittyagi <pi...@gmail.com>.
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.html
> as this is just code typed into a mail program!
>
> Regards,
>
> Kent
>
> On Fri, Feb 22, 2008 at 4:17 PM, sumittyagi <pi...@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-tp15627959p15627959.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-tp15627959p15641369.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
Re: How to get the doc ID from HITS
Posted by Kent Fitch <ke...@gmail.com>.
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 <pi...@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-tp15627959p15627959.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