On Thursday 09 March 2006 14:55, Samuru Jackson wrote: > Is there a way to save an object to the a lucene index? > > In my project I noticed that the performance bottleneck is my > database. Lucene gives back a result in no time but to retrieve the > corresponding data sets at the backend in the database can take long > especially if you need to execeute many queries. > > What I thought about is to store as much data as possible to the > indexed document and the best thing would be to save the model > (including corresponding relations 1:n and stuff like that). > > Is there a way to do that? We are using Lucene in a similar way, almost all fields are stored, and documents mostly contain properties from objects in our data model. We don't, however, store entire objects in a serialized form, instead we serialize property data types (fields) in our own way (in a way which makes them suitable for sorting and indexing, for instance). We are using Lucene as the search backend of our content repository implementation.
If you want to store an arbitrary Java object in an index document, you could always serialize it and store it as a binary field, see http://lucene.apache.org/java/docs/api/org/apache/lucene/document/Field.html and http://java.sun.com/j2se/1.4.2/docs/api/java/io/ByteArrayOutputStream.html http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectOutputStream.html This actually reminds me of a few questions I've been meaning to ask this list: - How does many stored fields eventually affect indexing/query performance compared to if no fields were stored (only indexed) ? - Are there any known scalability issues with a large amount of distinct fields in an index (not necessarily the same set of fields for every doc) ? Please ask me to rephrase/elaborate, if any of my questions are unclear or lacks info. Øyvind -- < Øyvind Stegard < oyviste at usit uio no >> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]