@Override
public EntityInfo extract(int scoreDocIndex) throws IOException {
int docId = queryHits.docId( scoreDocIndex );
Document document = extractDocument( scoreDocIndex );
EntityInfo entityInfo = extractEntityInfo( docId, document, scoreDocIndex, exceptionWrap );
Object[] eip = entityInfo.getProjection();
if ( eip != null && eip.length > 0 ) {
for ( int x = 0; x < projection.length; x++ ) {
if ( ProjectionConstants.SCORE.equals( projection[x] ) ) {
eip[x] = queryHits.score( scoreDocIndex );
}
else if ( ProjectionConstants.ID.equals( projection[x] ) ) {
eip[x] = entityInfo.getId();
}
else if ( ProjectionConstants.DOCUMENT.equals( projection[x] ) ) {
eip[x] = document;
}
else if ( ProjectionConstants.DOCUMENT_ID.equals( projection[x] ) ) {
eip[x] = docId;
}
else if ( ProjectionConstants.EXPLANATION.equals( projection[x] ) ) {
eip[x] = queryHits.explain( scoreDocIndex );
}
else if ( ProjectionConstants.OBJECT_CLASS.equals( projection[x] ) ) {
eip[x] = entityInfo.getClazz();
}
else if ( ProjectionConstants.SPATIAL_DISTANCE.equals( projection[x] ) ) {
eip[x] = queryHits.spatialDistance( scoreDocIndex );
}
else if ( ProjectionConstants.THIS.equals( projection[x] ) ) {
//THIS could be projected more than once
//THIS loading delayed to the Loader phase
entityInfo.getIndexesOfThis().add( x );
}
}
}
return entityInfo;
}