Is it possible to use Lucene without directory/files?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   tezcan_dilshener
Posted On:   Friday, April 2, 2004 06:15 AM

Hi I am new to Lucene and would like to know 1-) Can I Index entries from a collection, rather than files from a directory? I think the answer to this is, yes. 2-)Can I than execute a search query over this indexed collection rather than files from a directory? If the answer is Yes, can some one tell me how to construct a Search object using the indexed collection rather than the directory, please. If the answer is No, can anyone advise me how I can proceed? This is because we have huge number of Oracle table entries and need to search these entries without having to create text files first. Thanks in a   More>>

Hi


I am new to Lucene and would like to know

1-) Can I Index entries from a collection, rather than files from a directory?

I think the answer to this is, yes.


2-)Can I than execute a search query over this indexed collection rather than files from a directory?

If the answer is Yes, can some one tell me how to construct a Search object using the indexed collection rather than the directory, please.


If the answer is No, can anyone advise me how I can proceed?



This is because we have huge number of Oracle table entries and need to search these entries without having to create text files first.



Thanks in advance

   <<Less

Re: Is it possible to use Lucene without directory/files?

Posted By:   Anonymous  
Posted On:   Monday, April 5, 2004 02:35 PM

For indexing purposes, you can index from a database.
You grab each value that you want to index..eg

if sql is "select name, surname, id from person"
And if u have an object that will connect to the DB and return you each value given the key (fieldName like a Hashtable) then...


IndexWriter writer = IndexWriter(indexDir,analyzer,true);
Document d = new Document();
d.add(Field.Text("name",(String)resultRow.get("NAME")));
d.add(Field.UnIndexed("surname",(String)resultRow.get("SURNAME")));
d.addA(Field.Text("id",(String)resultRow.get("ID")));
writer.addDocument(d);

As you see the trick is just in grabbing each row (you can construct an object similar to resultRow)

Then build Field objects and add those Field objects into your Document object then add the document object into the writer.

The implementation that i wrote for my project incorporates using RAMDirectory object it makes it much more faster to index

It takes approx 7 secs to index 6000 records!

Re: Is it possible to use Lucene without directory/files?

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

1) Yes. Lucene is an IR library, not an application. Therefore, as long as you can construct Document objects from your data/collection (Oracle DB in your case), you can add those Documents to Lucene index, and effectively index your collection.


2) Yes. Use IndexSearcher class, as you can see in demo, in test cases, and check the Javadocs.

About | Sitemap | Contact