chobo
chobo

Reputation: 32291

Using Lucene with database data

I just started learning about Lucene and I get how it can be very useful for searching documents and such, but does anyone use it for searching database data?

For example,

I need to make a search that will search for keywords based on two fields ("description", "message").

To do this I would need to write an sql query to return all the description rows, and all the message rows (could be tens of thousands), then from that create an index, and search the index.

Is my understanding correct? I would first have to get all the data from the database which could be huge.

Upvotes: 2

Views: 3322

Answers (2)

Yavar
Yavar

Reputation: 11933

If you can (I mean if you are open to use anything), then try Solr. It has a built in support for indexing Database content using Data Import Handler. I am using it to index 1Billion+ rows of full text data residing in databases.

Upvotes: 5

Matt
Matt

Reputation: 26971

Your understanding is correct.

You would have to create an index for Lucene based on a set as you indicated. I would recommend Luke for viewing the indexes you created.

I have a warning though as to why Full Text Search is ultimately better -- Every time a value is updated, you have to update your Lucene index which is external to your database. This is overhead that I didn't want to deal with and ultimately ended up abandoning this very approach.

FTS gives me just as good results, at least for my needs, yours may differ.

Upvotes: 1

Related Questions