public EntityInfo extract(Hits hits,
int index) throws IOException {
Document doc = hits.doc( index );
//TODO if we are only looking for score (unlikely), avoid accessing doc (lazy load)
EntityInfo entityInfo = extract( doc );
Object[] eip = entityInfo.projection;
if ( eip != null && eip.length > 0 ) {
for (int x = 0; x < projection.length; x++) {
if ( ProjectionConstants.SCORE.equals( projection[x] ) ) {
eip[x] = hits.score( index );
}
else if ( ProjectionConstants.ID.equals( projection[x] ) ) {
eip[x] = entityInfo.id;
}
else if ( ProjectionConstants.DOCUMENT.equals( projection[x] ) ) {
eip[x] = doc;
}
else if ( ProjectionConstants.DOCUMENT_ID.equals( projection[x] ) ) {
eip[x] = hits.id( index );
}
else if ( ProjectionConstants.BOOST.equals( projection[x] ) ) {
eip[x] = doc.getBoost();
}
else if ( ProjectionConstants.EXPLANATION.equals( projection[x] ) ) {
eip[x] = searcher.explain( preparedQuery, hits.id( index ) );
}
else if ( ProjectionConstants.THIS.equals( projection[x] ) ) {
//THIS could be projected more than once
//THIS loading delayed to the Loader phase
entityInfo.indexesOfThis.add(x);
}
}
}
return entityInfo;
}
|