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 Ravi <ra...@siti.com> on 2005/12/14 12:52:13 UTC

Retriving the data from lucene

Thanks Erik,
I have already have the copy of the book and I am referencing  the book to
solve the problems .You have given very nice examples to solve the problems.
I am going on reading this book to solve my problems .

But I still have following problems . 

1) I want to store all the details of the my data in the lucene and I want
to retrieve from the lucene than storing in the database and retrieve that
from database .Is this technique is good or bad  or any other solution to
this type of  problem  Please suggest me.

2) I have one more problem is I want to retrieve the max 1000 docs from the
search. How can I solve this problem .

3) I want to display page by page max 100. 
	a) load all the data at a time and store in temp location and
display 			1-100 ,101-200 and so on.... 900-1000.
	b)  load only first 1-00 and whenever user clicks next 100 I want to
display next hundred by loading or searching again..
  I am not able to figure out how to get the details like this.. Could you
please help to solve this problem . Please I need to submit to my Seniors on
this weekend... I want to have really good solution which can not take much
time in terms of performance... I am waiting for your kind reply

Thanks
     Ravi 



-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
Sent: Tuesday, December 13, 2005 7:28 PM
To: java-user@lucene.apache.org
Subject: Re: :how to add int fileds to lucene:

Ravi,

A few great starting points... the code from http:// 
www.lucenebook.com (and it wouldn't hurt my feelings if you picked up  
a copy of the book itself too :), the examples from the many articles  
that have been written on Lucene, and last but not least, the unit  
tests of Lucene itself which is a great place to learn the API.

	Erik


On Dec 12, 2005, at 10:32 PM, Ravi wrote:

> Hi Erik
>
> Thanks for your solution. I want to do exactly what you have  
> mentioned in
> the mail . I would like to search on the fields what I have added  
> to lucene
> .That is search on  days and sort on those days value and moreover  
> how to
> add multiple field querys to lucene . I don't have any idea how to  
> Query on
> multiple fields .ex  searching on the candidate and days where days  
> >5 and
> candidate>10 or days >one month and so on.. Please give me the code  
> or let
> me know where I can find test programs so that I can complete my  
> project.
>
> Waiting for your reply....
>
> Thanks
> Ravi Kumar Jaladanki
> 408-328-6437
>
>
> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
> Sent: Monday, December 12, 2005 9:35 PM
> To: java-user@lucene.apache.org
> Subject: Re: :how to add int fileds to lucene:
>
>
> On Dec 12, 2005, at 8:10 AM, Ravi wrote:
>> I am trying to add some fields to lucene and I heard that adding
>> int values
>> are going to give much faster retrieval than adding to String
>> values. So I
>> want to add int values to document . But
>>
>>
>>
>> document.add(Field.Text("Candidate", objResultSet.getString
>> ("ROW_ID")));
>>
>> document.add(Field.Keyword("lastmodified",
>> objResultSet.getDate("MODIFIED_ON")));
>>
>> document.add(Field.Text("days",days) );
>>
>> document.add(Field.Text("contents", objReader));
>>
>>
>>
>>
>>
>> Days are int but it is giving error . Please suggest me with the
>> steps to
>> add and search those integer fields
>>
>
> All stored field data in a Lucene index are Strings.  The performance
> difference you may be referring to is with sorting results, not in
> retrieval.
>
> You will want to simply convert your int "days" into a String
> (Integer.toString(days) will do the trick.  Careful with your
> analyzer if you really do want days to be searchable/sortable.  Using
> Field.Keyword() is probably more appropriate.
>
> 	Erik
>
>
> ---------------------------------------------------------------------
> 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


---------------------------------------------------------------------
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: Retriving the data from lucene

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Dec 14, 2005, at 6:52 AM, Ravi wrote:
> 1) I want to store all the details of the my data in the lucene and  
> I want
> to retrieve from the lucene than storing in the database and  
> retrieve that
> from database .Is this technique is good or bad  or any other  
> solution to
> this type of  problem  Please suggest me.

This is one of those areas where it really depends.  It's fine to  
store information in Lucene, but whether that is best for your  
scenario really depends on the rest of your architecture.

> 2) I have one more problem is I want to retrieve the max 1000 docs  
> from the
> search. How can I solve this problem .

Stop iterating Hits after 1000 :)   Or use one of the other .search  
methods that allows you to specify (though this is entering expert- 
level API area) or use a HitCollector.

> 3) I want to display page by page max 100.
> 	a) load all the data at a time and store in temp location and
> display 			1-100 ,101-200 and so on.... 900-1000.
> 	b)  load only first 1-00 and whenever user clicks next 100 I want to
> display next hundred by loading or searching again..


The first hit here gives you some best practices:

	http://www.lucenebook.com/search?query=paging

The main idea is simply to re-search for each page, just picking up  
the Hits iteration at the proper offset.  If that is not performant  
enough, then it'd be time to seek another solution, but I've never  
had to go there myself.

	Erik


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