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 Lokeya <lo...@gmail.com> on 2007/04/10 08:40:15 UTC

Issue with search() Help Appreciated.

I have indexed the docs successfully under the directory "LUCENE" under
current directory, which have segments, _1.cfs and deletable.

Now trying to use the following code to search the index but not getting any
HITS. But when I try to read through Reader and get the document with field
mentioned it works which means the index done properly and its just that
search is not working. Code is as follows:

The following code gets a Hits object like :
org.apache.lucene.search.Hits@14a9972
But when i try to get hits.length() it is 0. 

Can anyone point out whats wrong ?

IndexSearcher isearcher = new IndexSearcher("./LUCENE");
QueryParser parser = new QueryParser("Description", analyzer);
Query query = parser.parse("based");
Hits hits = isearcher.search(query);
for (int i = 0; i < hits.length(); i++) 
{
	Document hitDoc = hits.doc(i);
}
isearcher.close();
directory.close();
-- 
View this message in context: http://www.nabble.com/Issue-with-search%28%29-Help-Appreciated.-tf3551357.html#a9914639
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: Issue with search() Help Appreciated.

Posted by Lokeya <lo...@gmail.com>.
The issue is solved. Luke was very helpful in debugging, infact it helped to
identify a very basic mistake we were making.


Lokeya wrote:
> 
> I solved the issue by using:
> 
> 1.Same Analyser.
> 2.Making indexing by tokenizing terms.
> 
> Now issue with the following code is, I am facing issues which I have
> pasted after the code, I searched the forum but couldn't find a relevant
> post :
> 
> QueryParser parser = new QueryParser("Title", analyzer);
> Query query = parser.parse("Cache");
>  Hits hits = isearcher.search(query);
> 
> Issues:
> --------
> 1. Not getting relevant documents.
> 2. Suprisingly and ugly though -> Getting same number for the
> Hits.length() which is 21 and then gives OutOfMemoryError.
> 
> Infact I realised I should give details of what I want to do may be that
> wud help someone to tell whats the issue:
> 
> I have document with field : "Tiltle" and "Description" which I have
> indexed and I am searching one of these fields for certain terms. Is my
> above code fine or I shud be using the query in some other manner. 
> 
> Please Advice.
> 
> 
> Daniel Naber-5 wrote:
>> 
>> On Tuesday 10 April 2007 08:40, Lokeya wrote:
>> 
>>> But when i try to get hits.length() it is 0.
>>>
>>> Can anyone point out whats wrong ?
>> 
>> Please check the FAQ first:
>> http://wiki.apache.org/lucene-java/LuceneFAQ#head-3558e5121806fb4fce80fc022d889484a9248b71
>> 
>> Regards
>>  Daniel
>> 
>> -- 
>> http://www.danielnaber.de
>> 
>> ---------------------------------------------------------------------
>> 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/Issue-with-search%28%29-Help-Appreciated.-tf3551357.html#a9963775
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: Issue with search() Help Appreciated.

Posted by Lokeya <lo...@gmail.com>.
I solved the issue by using:

1.Same Analyser.
2.Making indexing by tokenizing terms.

Now issue with the following code is, I am facing issues which I have pasted
after the code, I searched the forum but couldn't find a relevant post :

QueryParser parser = new QueryParser("Title", analyzer);
Query query = parser.parse("Cache");
 Hits hits = isearcher.search(query);

Issues:
--------
1. Not getting relevant documents.
2. Suprisingly and ugly though -> Getting same number for the Hits.length()
which is 21 and then gives OutOfMemoryError.

Infact I realised I should give details of what I want to do may be that wud
help someone to tell whats the issue:

I have document with field : "Tiltle" and "Description" which I have indexed
and I am searching one of these fields for certain terms. Is my above code
fine or I shud be using the query in some other manner. 

Please Advice.


Daniel Naber-5 wrote:
> 
> On Tuesday 10 April 2007 08:40, Lokeya wrote:
> 
>> But when i try to get hits.length() it is 0.
>>
>> Can anyone point out whats wrong ?
> 
> Please check the FAQ first:
> http://wiki.apache.org/lucene-java/LuceneFAQ#head-3558e5121806fb4fce80fc022d889484a9248b71
> 
> Regards
>  Daniel
> 
> -- 
> http://www.danielnaber.de
> 
> ---------------------------------------------------------------------
> 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/Issue-with-search%28%29-Help-Appreciated.-tf3551357.html#a9932151
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: Issue with search() Help Appreciated.

Posted by Daniel Naber <lu...@danielnaber.de>.
On Tuesday 10 April 2007 08:40, Lokeya wrote:

> But when i try to get hits.length() it is 0.
>
> Can anyone point out whats wrong ?

Please check the FAQ first:
http://wiki.apache.org/lucene-java/LuceneFAQ#head-3558e5121806fb4fce80fc022d889484a9248b71

Regards
 Daniel

-- 
http://www.danielnaber.de

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