br=BoboRequestBuilder.buildRequest(solrParams,query,sort);
}
catch(Exception e){
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}
BrowseResult res = null;
if (shardsVal == null && !solrParams.getBool(ShardParams.IS_SHARD, false))
{
SolrIndexSearcher searcher=rb.req.getSearcher();
SolrIndexReader solrReader = searcher.getReader();
BoboIndexReader reader = (BoboIndexReader)solrReader.getWrappedReader();
if (reader instanceof BoboIndexReader){
try {
List<Query> filters = rb.getFilters();
if (filters!=null){
final ArrayList<DocIdSet> docsets = new ArrayList<DocIdSet>(filters.size());
for (Query filter : filters){
Weight weight = filter.createWeight(rb.req.getSearcher());
final Scorer scorer = weight.scorer(reader, false, true);
docsets.add(new DocIdSet(){
@Override
public DocIdSetIterator iterator() throws IOException {
return scorer;
}
});
}
if (docsets.size()>0){
br.setFilter(
new Filter(){
@Override
public DocIdSet getDocIdSet(IndexReader reader)
throws IOException {
return new AndDocIdSet(docsets);
}
});
}
}
Set<String> facetNames = reader.getFacetNames();
Set<String> returnFields = rb.rsp.getReturnFields();
Set<String> storedFields = new HashSet<String>();
if (returnFields!=null){
for (String fld : returnFields){
if (!facetNames.contains(fld)){
storedFields.add(fld);
}
}
br.setFetchStoredFields(!storedFields.isEmpty());
}
BoboBrowser browser = new BoboBrowser(reader);
res=browser.browse(br);
} catch (Exception e) {
logger.error(e.getMessage(),e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,e.getMessage(),e);
}
}
else{
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"invalid reader, please make sure BoboIndexReaderFactory is set.");
}
}
else{
// multi sharded request
String[] shards = shardsVal.split(",");
res = DispatchUtil.broadcast(_threadPool, solrParams, br, shards, 5);
}
SolrDocumentList docList = new SolrDocumentList();
docList.setNumFound(res.getNumHits());
docList.setStart(br.getOffset());
rb.stage = ResponseBuilder.STAGE_GET_FIELDS;
boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
BrowseHit[] hits = res.getHits();
if (hits!=null){
for (BrowseHit hit : hits){
SolrDocument doc = convert(hit,rb.rsp.getReturnFields());
if (doc!=null){
if (returnScores){