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 22:32:29 UTC
Problem in Coding, to get the DOC ID from HITS
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 error i am getting is
C:\Documents and Settings\Sumit\Desktop>javac db/comm.java
db/comm.java:15: variable hits might not have been initialized
int hitCount = hits.length();
^
db/comm.java:17: unreported exception java.io.IOException; must be caught or
dec
lared to be thrown
int docId = hits.id(i) ;
^
2 errors
any help please..
--
View this message in context: http://www.nabble.com/Problem-in-Coding%2C-to-get-the-DOC-ID-from-HITS-tp15641665p15641665.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: Problem in Coding, to get the DOC ID from HITS
Posted by Erick Erickson <er...@gmail.com>.
You have to set the Hits object to the results of a search. See
Searcher.search()
On Fri, Feb 22, 2008 at 4:32 PM, sumittyagi <pi...@gmail.com> wrote:
>
> 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 error i am getting is
>
> C:\Documents and Settings\Sumit\Desktop>javac db/comm.java
> db/comm.java:15: variable hits might not have been initialized
> int hitCount = hits.length();
> ^
> db/comm.java:17: unreported exception java.io.IOException; must be caught
> or
> dec
> lared to be thrown
> int docId = hits.id(i) ;
> ^
> 2 errors
>
>
>
> any help please..
>
>
> --
> View this message in context:
> http://www.nabble.com/Problem-in-Coding%2C-to-get-the-DOC-ID-from-HITS-tp15641665p15641665.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: Problem in Coding, to get the DOC ID from HITS
Posted by Dharmalingam Ganesan <dg...@fc-md.umd.edu>.
Of course, these are programming errors nothing really related to
Lucene.
Hits hits;
Int hitCount = hits.length
This does not make sense. You have just declared hits. It must be
created before using it.
The second error should disapper if you add throws declaration or
try/catch block.
By the way, avoid asking such questions in this forum because the
questions are not related to Lucene!!
-----Original Message-----
From: sumittyagi [mailto:ping.sumit@gmail.com]
Sent: Friday, February 22, 2008 4:32 PM
To: java-user@lucene.apache.org
Subject: Problem in Coding, to get the DOC ID from HITS
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 error i am getting is
C:\Documents and Settings\Sumit\Desktop>javac db/comm.java
db/comm.java:15: variable hits might not have been initialized
int hitCount = hits.length();
^
db/comm.java:17: unreported exception java.io.IOException; must be
caught or
dec
lared to be thrown
int docId = hits.id(i) ;
^
2 errors
any help please..
--
View this message in context:
http://www.nabble.com/Problem-in-Coding%2C-to-get-the-DOC-ID-from-HITS-t
p15641665p15641665.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