File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes how to build a search engine? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "how to build a search engine?" Watch "how to build a search engine?" New topic

how to build a search engine?

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi All,

I would like to build a search engine in my application. For this I have a text box where the user can input any text. I would like to search (%like%) for the text the user has provided against all tables/columns in the db.

is there any design pattern for which I should use to achieve this? I don't wish to build a query with m*n (tables X columns) with any %like% statement.

thank you
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
I don't think we have design pattern for this (at least I am not aware of) What will you do with the search result? If you need to search through more than one column the best way is to have concatenated value of all the key columns as one column or through view and search the result. However if the query is based on the view there is possibility that this query may never return or timeout.

If this search feature is really important the best way I would do is
- Create a new column with concatenation of all the key columns
- Create text/interMedia index (I assumed you were using Oracle from syntax %LIKE%)

I don't wish to build a query with m*n

You don't have to manually write the SQL, you can generate the SQL using the meta data tables like ALL_TABLES, ALL_TAB_COLUMNS (in Oracle) . I wouldn't try this as this wouldn't give me any meaningful information without right indexes.

Explore the text index it has lot for features than simple string match.
[ April 06, 2007: Message edited by: Purushothaman Thambu ]
I agree. Here's the link:
subject: how to build a search engine?
It's not a secret anymore!