How can I use IndexWriter to index in memory values rather than text files?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   tezcan_dilshener
Posted On:   Friday, April 2, 2004 03:58 AM

Hi I am new to Lucene and would like to implement it to do fuzzysearch over our Oracle db entries. We want to be able to search name field. Looking at Lucene and how it is implemented in sample applications, I see that one needs to always index entries from a text file. I can do the following 1- select all records from the Oracle table 2- create a text file with the content as the name field from the selection. 3- name the text file as the primary key of the teble entry. 4- Index the text files content 5- Search it 6- from the result set, get the primary key (the text file name) value of the matching entry 7- use the key    More>>

Hi
I am new to Lucene and would like to implement it to do fuzzysearch over our Oracle db entries.
We want to be able to search name field.


Looking at Lucene and how it is implemented in sample applications, I see that one needs to always index entries from a text file.
I can do the following


1-
select all records from the Oracle table

2- create a text file with the content as the name field from the selection.

3- name the text file as the primary key of the teble entry.

4- Index the text files content

5- Search it

6- from the result set, get the primary key (the text file name) value of the matching entry

7- use the key to show the details


However the above seems to be very cumborsome, since we have thousands of entries in th name table!

Is there a way to trick the IndexWriter so that instead of text files being pass to it, I can add String, numeric values to it?



In the above steps that I have thought of, would it be possible to by pass steps 2 and 3 so that during indexing,

I pass name and its primary key value to it?


Any assistance and guidelines would be much apreciated.


Many Thans in advance
T.Dilshener

   <<Less

Re: How can I use IndexWriter to index in memory values rather than text files?

Posted By:   Otis_Gospodnetic  
Posted On:   Saturday, April 3, 2004 02:17 AM

You are probably looking at a Lucene demo, and assuming that Lucene can index only files. That is not correct. Lucene can index anything that can be converted to text (Java Strings).


There is no need for you to dump your DB data to files.
Just select your data, create String variables containing your data, then use those Strings to create Fields in a Lucene Document, and then add such Documents to a Lucene index using IndexWriter.

About | Sitemap | Contact