anchor.diff:  
   send_delete(Doc) ->
       post_to_solr(update_payload([], [Doc])).
  -
  -%% @doc Send items accumulated in the index expand context to
  -%% Solr. The URL used to talk to Solr is embedded in the context
  -%% object and determined when `{@link init_items/1}' was called.
  --spec send_items(pid() | index_expand_ctx()) -> ok | {error, {_, _}}.
  -send_items(Pid) when is_pid(Pid)->
  -    % Adding a timeout of 30s as preprod is very, very slow
  -    gen_server:call(Pid, send_items, 30000).
  -send_items_impl(#idx_exp_ctx{to_add = Added, to_del = Deleted,
  -                        count = Count,
  -                        received = Count,
  -                       send_requested = Requestor,
  -                       send_fun = SendFun}) when Requestor /= undefined ->
  -    Result = case {Added, Deleted} of
  -        {[], []} ->
  -            ok;
  -        {UnsortedToAdd, UnsortedToDel} ->
  -            ToAdd = sort(UnsortedToAdd),
  -            ToDel = sort(UnsortedToDel),
  -            error_logger:info_msg("chef_index_expand:send_items adds:~p dels:~p~n",
  -                                  [length(ToAdd), length(ToDel)]),
  -            Doc = update_payload(ToAdd, ToDel),
  -            SendFun(Doc)
  -             end,
  -    gen_server:reply(Requestor, Result),
  -    #idx_exp_ctx{};
  -send_items_impl(State) ->
  -    State.
   
   %% --- start copy from chef_index (chef_index_queue) ---
   
  
positive.code: -define(META_FIELDS, [{?K_ID, <<"X_CHEF_id_CHEF_X">>},
                        {?K_DATABASE, <<"X_CHEF_database_CHEF_X">>}]).
  
  -record(idx_exp_ctx, {
            count = 0,
            current = 0,
            received = 0,
            to_add = [],
            to_del = [],
            send_requested = undefined,
            send_fun = fun post_to_solr/1
           }).
  
  -opaque index_expand_ctx() :: #idx_exp_ctx{}.
  -export_type([index_expand_ctx/0]).
  
  %% @doc Create a new index expand context.
  -spec init_items(pid(), non_neg_integer()) -> ok.
  init_items(Pid, NumberItems) ->
      gen_server:cast(Pid, {init_items,NumberItems}).
  
  add_item(Pid, Id, Ejson, Index, OrgId) ->
      gen_server:cast(Pid, {add_item, Id, Ejson, Index, OrgId}).
  
  delete_item(Pid, Id, Index, OrgId) ->
      gen_server:cast(Pid, {delete_item, Id, Index, OrgId}).
  
  chef_object_type(Index) when is_binary(Index) -> {data_bag_item, Index};
  chef_object_type(Index) when is_atom(Index)   -> Index.
  
  
negative.code: %%
  %% This module implements Chef object flatten/expand using the same
  %% algorithm as `chef-expander' and handles POSTing updates (both adds
  %% and deletes) to Solr.
  %%
  %% @end
  -module(chef_index_expand).
  
  -export([make_command/5,
           post_multi/2,
           post_single/2,
           post_to_solr/1,
           send_item/1,
           send_delete/1,
           doc_for_index/4,
           doc_for_delete/3]).
  
  -define(SERVER, ?MODULE).
  
  