anchor.diff:  %%
   %% This module implements Chef object flatten/expand using the same
   %% algorithm as `chef-expander' and handles POSTing updates (both adds
  -%% and deletes) to Solr. You will interact with four functions:
  -%%
  -%% <ol>
  -%% <li>{@link init_items/1}</li>
  -%% <li>{@link add_item/4}</li>
  -%% <li>{@link delete_item/4}</li>
  -%% <li>{@link send_items/1}</li>
  -%% </ol>
  -%%
  -%% Start by initializing an item context object using {@link
  -%% init_items/1} to which you pass the URL for the Solr instance you
  -%% want to work with.
  -%%
  -%% Next, use {@link add_item/4} to add/update items in the
  -%% index. These items will go through the flatten/expand process. If
  -%% you want to stage an item delete, use {@link delete_item/4}. Both
  -%% of these functions take an item context object and return a
  -%% possibly updated context. It is important to keep track of the
  -%% possibly modified context to use for your next call. This API
  -%% allows this module to handle the flatten/expand and post in
  -%% different ways. For example, the flatten/expand can be done inline,
  -%% accumulating the result in the context, or the context can contain
  -%% a pid and the work can be done async and in parallel.
  -%%
  -%% Finally, call {@link send_items/1} passing the accumulated context
  -%% object. Calling this function triggers the actual POST to solr.
  +%% and deletes) to Solr.
   %%
   %% @end
   -module(chef_index_expand).
   
  --export([
  -         start_link/0,
  -         add_item/5,
  -         delete_item/4,
  -         init_items/2,
  -         make_command/5,
  +-export([make_command/5,
            post_multi/2,
            post_single/2,
            post_to_solr/1,
  -         send_items/1,
            send_item/1,
            send_delete/1,
            doc_for_index/4,
  -         doc_for_delete/3,
  -         stop/1,
  -         gather/1
  -        ]).
  --behaviour(gen_server).
  -
  -%% gen_server callbacks
  --export([init/1, handle_call/3, handle_cast/2, handle_info/2,
  -         terminate/2, code_change/3]).
  +         doc_for_delete/3]).
   
   -define(SERVER, ?MODULE).
   
  
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: 
  send_delete(Doc) ->
      post_to_solr(update_payload([], [Doc])).
  
  %% --- start copy from chef_index (chef_index_queue) ---
  
  