lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Olenin" <>
Subject injecting fields looked up from DB at the runtime - Solr/Lucene question
Date Sun, 05 Nov 2006 05:55:13 GMT


I wonder if the below is the correct way of doing things...

- when the Hits objects are returned from IndexSearcher (as a result of some search), 'inject'
'info' fields into the 'Hit' objects at runtime by looking the values up in the DB. The main
purpose is to avoid storing 'info' fields in the index as 'stored' fields.
  * in other words, I want to keep in Lucene index ONLY 'indexed' fields and keep all 'stored'
fields (some of which might be big BLOB entries) in relational DB. I do want however to provide
'generic' transparent access to these stored fields through Lucene APIs (one of the rational
is to be able to use some frameworks around, like Solr, transparently, no matter which fields
are stored in index and which are stored in the DB).

I wonder if adding 'Fields' to the returned Document object (linked with Hit object) will
do the trick for me? In other words, will the below work?

Hits hits =;
HitsIterator iter = (HitsIterator)hits.iterator();
Hit hit = (Hit);
Document doc = hit.getDocument();
String docId = doc.getField("docId");
doc.addField(getFieldBy("someStoredDBField", docId));

Would this disturb the index in any way? Would this be reflected in all other objects in the
returned Hits set (eg, will 'hit.get("someStoredDBField")' return the value looked up in the



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message