anchor.diff:           to_json/2]).
   
   -include_lib("webmachine/include/webmachine.hrl").
  +-include("../../chef_common/src/chef_solr.hrl").
   -include("chef_rest_search_resource.hrl").
   
   -define(db_for_guid(X), [<<"chef_">>, X]).
  
positive.code: 
  make_search_results(S, Db, Ids, BatchSize, Start, NumFound) ->
      Ans0 = search_result_start(Start, NumFound),
      Ans1 = fetch_result_rows(Ids, BatchSize, S, ?db_for_guid(Db), Ans0),
      search_result_finish(Ans1).
  
  % @doc Fetch a list of `Ids' in batches of size `BatchSize'.
  %
  
negative.code: % remove the JSON array markers.  The caller is responsible for adding
  % this back to create valid JSON.
  %
  fetch_result_rows([], _BatchSize, _S, _Db, {N, Acc}) ->
      {N, Acc};
  fetch_result_rows(Ids, BatchSize, S, Db, {N, Acc}) when is_list(Ids) ->
      fetch_result_rows(safe_split(BatchSize, Ids), BatchSize, S, Db, {N, Acc});
  fetch_result_rows({Ids, []}, _BatchSize, S, Db, {N, Acc}) ->
      Docs = chef_otto:bulk_get(S, Db, Ids),
      {N + length(Docs), encode_results(Docs, Acc)};
  fetch_result_rows({Ids, Rest}, BatchSize, S, Db, {N, Acc}) ->
      Next = safe_split(BatchSize, Rest),
      Docs = chef_otto:bulk_get(S, Db, Ids),
      fetch_result_rows(Next, BatchSize, S, Db,
                        {N + length(Docs),
                         encode_results(Docs, <<",">>, Acc)}).
  
  encode_results([], Acc) ->
      Acc;
  