}
else if ("asc".equals(order) || "bottom".equals(order)) {
top = false;
}
else {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Unknown sort order: "+order);
}
part = part.substring( 0, idx ).trim();
}
else {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Missing sort order." );
}
if( "score".equals(part) ) {
if (top) {
// If thre is only one thing in the list, just do the regular thing...
if( parts.length == 1 ) {
return null; // do normal scoring...
}
lst[i] = SortField.FIELD_SCORE;
}
else {
lst[i] = new SortField(null, SortField.SCORE, true);
}
}
else {
// getField could throw an exception if the name isn't found
SchemaField f = null;
try{
f = schema.getField(part);
}
catch( SolrException e ){
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "can not sort on undefined field: "+part, e );
}
if (f == null || !f.indexed()){
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "can not sort on unindexed field: "+part );
}
lst[i] = f.getType().getSortField(f,top);
}
}
// For more info on the 'num' field, -1,