Meaningless Drivel is fun!
The moose likes Other Open Source Projects and the fly likes Lucene, indexing an Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Lucene, indexing an Object" Watch "Lucene, indexing an Object" New topic

Lucene, indexing an Object

Fahed Siddiqui

Joined: Jun 24, 2004
Posts: 6

freinds I m using Lucene for searching and sorting string data on my web pages.
the problem is that Lucene stores/index only text(as far as I know) while i want to store java objects, in other words when a search is found in a document I would be able to retreive a particular Object associated with that document.
Is it possible that I store Object's hash Code in string form to the Lucene indexed directory and retrieve object on the basis of hash code.
In simple words forget indexing forget Lucene just tell me is it possible that if u have hash code (String form) ,can u reference/retrieve an existing object using that hash code,if yes then how ? I wil be very thankful to u if u solve my problem.

Take care,
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
The way I approach this is to store the primary key of the object alongside the attributes/fields that you are indexing. That way, you can grab the key and lookup the appropriate object when performing a search.

Hashcode should work, but only if you know it's unique and you have a way to convert from a hashcode back to the object. You'll need to write this yourself.
I agree. Here's the link:
subject: Lucene, indexing an Object
jQuery in Action, 3rd edition