This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Working with Lucene - a design issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Working with Lucene - a design issue" Watch "Working with Lucene - a design issue" New topic
Author

Working with Lucene - a design issue

Faraz Ali
Ranch Hand

Joined: May 15, 2008
Posts: 108
Hi All,

I am writtng an application in lucene, in which i am retreiving records from db and indexing it. When i search the index, its gives me Lucene's objects in result, but i want it to return collection which contain my own objects, so that it is easy to use.

Say, i indexed the whole book table from db into lucene indexes. Now i am searching the index by author name, i want it to return a collection which contains all Book objects with the desired author.

Thank you,
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
The normal use case for Lucene would be that the results contain everything that is needed to display a list of search results, but not more than that (in particular not ALL information). In the case of books this might be title, author and ISBN (and maybe a DB ID if that's needed to identify a book uniquely). In most cases not all information is part of the index anyway, in which case you'd need to hit the DB to get the rest of it - and then you might use SQL to perform the search instead of Lucene to begin with.

So I'd say that the Lucene search should return the minimal set of information needed for display, and once a user selects a particular book, the DB can be accessed to retrieve all information about it.

Or do you have in fact ALL information about the book in the index? Then it shouldn't be hard to recreate a Book object from the search results, but then the question becomes: why use a DB for storing the information in the first place, instead of just a Lucene index?


Ping & DNS - my free Android networking tools app
Faraz Ali
Ranch Hand

Joined: May 15, 2008
Posts: 108
Many Thanks,

One more question, whats the best strategy to index multiple tables?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
Not sure what you're getting at - how (or why) would indexing multiple tables be different from indexing a single table? Obviously, you'd want the table name in your Document, so that you'll know from which table a query result originates.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Working with Lucene - a design issue
 
Similar Threads
Lucene : Where to use exactly
Is this good enough?
Hibernate Search in Action: What do you mean by Search exactly?
Lucene in Action: integration with db?
ORM Mapping, Best practices?