Map<String, FacetHandler<?>> facetHandlerMap = browser.getFacetHandlerMap();
int i = 0;
for (ScoreDoc doc : scoreDocs) {
BrowseHit hit = new BrowseHit();
hit.setScore(doc.score);
hit.setDocid(doc.doc);
Map<String,String[]> map = new HashMap<String,String[]>();
Map<String,Object[]> rawMap = new HashMap<String,Object[]>();
for (Map.Entry<String, FacetHandler<?>> entry : facetHandlerMap.entrySet()) {
map.put(entry.getKey(), browser.getFieldVal(doc.doc, entry.getKey()));
rawMap.put(entry.getKey(), browser.getRawFieldVal(doc.doc, entry.getKey()));
}
hit.setFieldValues(map);
hit.setRawFieldValues(rawMap);
hits[i++] = hit;
}
res = new BrowseResult();
res.setHits(hits);
res.addAll(facetCollectors);
res.setTid(req.getTid());
totalHits = (Integer) collector.getClass().getMethod(GET_TOTAL_HITS_METHOD).invoke(collector);
res.setNumHits(totalHits);
res.setNumGroups(totalHits);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
if (req.getMapReduceWrapper() != null) {
result.setMapReduceResult(req.getMapReduceWrapper().getResult());
}
SenseiHit[] senseiHits = new SenseiHit[hits.length];
Set<String> selectSet = senseiRequest.getSelectSet();
for (int i = 0; i < hits.length; i++)
{
BrowseHit hit = hits[i];
SenseiHit senseiHit = new SenseiHit();
int docid = hit.getDocid();
SubReaderInfo<BoboIndexReader> readerInfo = subReaderAccessor.getSubReaderInfo(docid);
Long uid = (Long)hit.getRawField(PARAM_RESULT_HIT_UID);
if (uid == null)
uid = ((ZoieIndexReader<BoboIndexReader>) readerInfo.subreader.getInnerReader()).getUID(readerInfo.subdocid);
senseiHit.setUID(uid);
senseiHit.setDocid(docid);
senseiHit.setScore(hit.getScore());
senseiHit.setComparable(hit.getComparable());
if (selectSet != null && selectSet.size() != 0)
{
// Clear the data those are not used:
if (hit.getFieldValues() != null)
{
Iterator<String> iter = hit.getFieldValues().keySet().iterator();
while (iter.hasNext())
{
if (!selectSet.contains(iter.next()))
{
iter.remove();
}
}
}
if (hit.getRawFieldValues() != null)
{
Iterator<String> iter = hit.getRawFieldValues().keySet().iterator();
while (iter.hasNext())
{
if (!selectSet.contains(iter.next()))
{
iter.remove();
}
}
}
}
if (features != null) {
senseiHit.setFeatures(features[i]);
}
senseiHit.setFieldValues(hit.getFieldValues());
senseiHit.setRawFieldValues(hit.getRawFieldValues());
senseiHit.setStoredFields(hit.getStoredFields());
senseiHit.setExplanation(hit.getExplanation());
senseiHit.setGroupField(hit.getGroupField());
senseiHit.setGroupValue(hit.getGroupValue());
senseiHit.setRawGroupValue(hit.getRawGroupValue());
senseiHit.setGroupHitsCount(hit.getGroupHitsCount());
senseiHit.setTermFreqMap(hit.getTermFreqMap());
senseiHits[i] = senseiHit;
}
result.setHits(senseiHits);
result.setNumHits(res.getNumHits());