anchor.diff:      %% Body is the last since including head or exact will duplicate results.
       ResultBody.
   
  -preview_exact(_IndexTable, _ID, _Type, _SearchTerm, _Key, 0, _Iff) -> [];
  -preview_exact(IndexTable, ID, ivk, SearchTerm, Key, Limit, Iff) ->
  +-spec preview_exact_unique(atom(), integer(), binary(), term(), integer(), function(), list()) -> list().
  +preview_exact_unique(_IndexTable, _ID, _SearchTerm, _Key, 0, _Iff, Acc) -> Acc;
  +preview_exact_unique(IndexTable, ID, SearchTerm, Key, Limit, Iff, Acc) ->
       case imem_if:next(IndexTable, {ID, SearchTerm, Key}) of
  -        '$end_of_table' -> [];
  +        '$end_of_table' -> Acc;
           {ID, SearchTerm, NextKey} = Stu ->
               case Iff({NextKey, SearchTerm}) of
                   true ->
  -                    [build_result_entry(Stu, exact_match, NextKey, SearchTerm) |
  -                     preview_exact(IndexTable, ID, ivk, SearchTerm, NextKey, Limit-1, Iff)];
  +                    NewLimit = case lists:keyfind(SearchTerm, 3, Acc) of
  +                        false -> Limit -1;
  +                        _ -> Limit
  +                    end,
  +                    NewAcc = [build_result_entry(Stu, exact_match, NextKey, SearchTerm) | Acc],
  +                    preview_exact_unique(IndexTable, ID, SearchTerm, NextKey, NewLimit, Iff, NewAcc);
                   false ->
  -                    preview_exact(IndexTable, ID, ivk, SearchTerm, NextKey, Limit, Iff)
  -            end;
  -        _ -> []
  -    end;
  +                    preview_exact_unique(IndexTable, ID, SearchTerm, NextKey, Limit, Iff, Acc)
  +            end;
  +        _ -> Acc
  +    end.
  +
  +preview_exact(_IndexTable, _ID, _Type, _SearchTerm, _Key, 0, _Iff) -> [];
  +preview_exact(IndexTable, ID, ivk, SearchTerm, Key, Limit, Iff) ->
  +    lists:reverse(preview_exact_unique(IndexTable, ID, SearchTerm, Key, Limit, Iff, []));
   preview_exact(IndexTable, ID, iv_k, SearchTerm, _Key, _Limit, Iff) ->
       case imem_if:read(IndexTable, {ID, SearchTerm}) of
           [#ddIndex{stu = {ID, SearchTerm}, lnk = Key} = Entry] ->
  
positive.code: %% @doc Preview match scan into an index for finding first "best" matches
  -spec preview(atom(),integer(),atom(),list(),term(),integer(),function(),function()) -> list().
  preview(IndexTable,ID,Type,_SearchStrategies,{RangeStart, RangeEnd},Limit,Iff,Vnf) ->
      R = {Vnf(RangeStart), Vnf(RangeEnd)},
      case {Vnf(RangeStart), Vnf(RangeEnd)} of
          {[?nav], _} -> [];
          {_, [?nav]} -> [];
  
negative.code:             end;
          _ -> []
      end;
  preview_exact(IndexTable, ID, iv_kl, SearchTerm, _Key, _Limit, Iff) ->
      case imem_if:read(IndexTable, {ID, SearchTerm}) of
          [#ddIndex{stu = {ID, SearchTerm}, lnk = KeyList} = Entry] ->
              preview_expand_kl(exact_match, Entry#ddIndex.stu, KeyList, SearchTerm, Iff);
          _ -> []
      end;
  preview_exact(IndexTable, ID, iv_h, SearchTerm, _Key, _Limit, Iff) ->
      case imem_if:read(IndexTable, {ID, SearchTerm}) of
          [#ddIndex{stu = {ID, SearchTerm}, lnk = Hash}] ->
              preview_expand_hash(exact_match, IndexTable, ID, Hash, SearchTerm, ?SMALLEST_TERM, Iff);
          _ -> []
      end.
  
  -spec preview_head_unique(atom(), integer(), binary(), tuple(), integer(), function(), list()) -> list().
  preview_head_unique(_IndexTable, _ID, _SearchTerm, _PrevStu, 0, _Iff, Acc) -> Acc;
  preview_head_unique(IndexTable, ID, SearchTerm, PrevStu, Limit, Iff, Acc) ->
      SizeSearch = size(SearchTerm),
      case imem_if:next(IndexTable, PrevStu) of
          '$end_of_table' -> Acc;
          {ID, <<SearchTerm:SizeSearch/binary, _/binary>> = Value, Key} = Stu ->
              case Iff({Key, Value}) of
                  true ->
                      NewLimit = case lists:keyfind(Value, 3, Acc) of
                          false -> Limit -1;
                          _ -> Limit
                      end,
                      NewAcc = [build_result_entry(Stu, head_match, Key, Value) | Acc],
                      preview_head_unique(IndexTable, ID, SearchTerm, Stu, NewLimit, Iff, NewAcc);
                  false ->
                      preview_exact_unique(IndexTable, ID, SearchTerm, Stu, Limit, Iff, Acc)
              end;
          _ -> Acc
      end.
  
  preview_head(_IndexTable, _ID, _Type, _SearchTerm, _Stu, 0, _Iff) -> [];
  preview_head(IndexTable, ID, ivk, SearchTerm, PrevStu, Limit, Iff) ->
      lists:reverse(preview_head_unique(IndexTable, ID, SearchTerm, PrevStu, Limit, Iff, []));
  preview_head(IndexTable, ID, iv_k, SearchTerm, {ID, Value} = Stu, Limit, Iff) ->
      Partial = case imem_if:read(IndexTable, Stu) of
          [#ddIndex{stu = {ID, Value}, lnk = Key} = Entry] ->
              case Iff({Key, Value}) of
                  true ->
                      [build_result_entry(Entry#ddIndex.stu, head_match, Key, Value)];
                  false -> []
              end;
          _ -> []
      end,
      SizeSearch = size(SearchTerm),
      case imem_if:next(IndexTable, Stu) of
          '$end_of_table' -> Partial;
          {ID, <<SearchTerm:SizeSearch/binary, _/binary>>} = NextStu ->
              Partial ++ preview_head(IndexTable, ID, iv_k, SearchTerm, NextStu, Limit - 1, Iff);
          _ -> Partial
      end;
  preview_head(IndexTable, ID, iv_kl, SearchTerm, {ID, Value} = Stu, Limit, Iff) ->
      Partial = case imem_if:read(IndexTable, Stu) of
          [#ddIndex{stu = {ID, Value}, lnk = KeyList} = Entry] ->
              preview_expand_kl(head_match, Entry#ddIndex.stu, KeyList, Value, Iff);
          _ -> []
      end,
      SizeSearch = size(SearchTerm),
      case imem_if:next(IndexTable, Stu) of
          '$end_of_table' -> Partial;
          {ID, <<SearchTerm:SizeSearch/binary, _/binary>>} = NextStu ->
              Partial ++ preview_head(IndexTable, ID, iv_kl, SearchTerm, NextStu, Limit - 1, Iff);
          _ -> Partial
      end;
  preview_head(IndexTable, ID, iv_h, SearchTerm, {ID, Value} = Stu, Limit, Iff) ->
      Partial = case imem_if:read(IndexTable, Stu) of
          [#ddIndex{stu = {ID, Value}, lnk = Hash}] ->
              preview_expand_hash(head_match, IndexTable, ID, Hash, Value, ?SMALLEST_TERM, Iff);
          _ -> []
      end,
      SizeSearch = size(SearchTerm),
      case imem_if:next(IndexTable, Stu) of
          '$end_of_table' -> Partial;
          {ID, <<SearchTerm:SizeSearch/binary, _/binary>>} = NextStu ->
              Partial ++ preview_head(IndexTable, ID, iv_h, SearchTerm, NextStu, Limit - 1, Iff);
          _ -> Partial
      end.
  
  -spec preview_body_unique(atom(), integer(), binary(), tuple(), integer(), function(), list()) -> list().
  preview_body_unique(_IndexTable, _ID, _SearchTerm, _Stu, 0, _Iff, Acc) -> Acc;
  preview_body_unique(IndexTable, ID, SearchTerm, PrevStu, Limit, Iff, Acc) ->
      case imem_if:next(IndexTable, PrevStu) of
          '$end_of_table' -> Acc;
          {ID, Value, Key} = Stu ->
              case binary:match(Value, SearchTerm) =/= nomatch andalso Iff({Key, Value}) of
                  true ->
                      NewLimit = case lists:keyfind(Value, 3, Acc) of
                          false -> Limit -1;
                          _ ->  Limit
                      end,
                      NewAcc = [build_result_entry(Stu, body_match, Key, Value) | Acc],
                      preview_body_unique(IndexTable, ID, SearchTerm, Stu, NewLimit, Iff, NewAcc);
                  false ->
                      preview_body_unique(IndexTable, ID, SearchTerm, Stu, Limit, Iff, Acc)
              end;
          _ -> Acc
      end.
  
  
  preview_body(_IndexTable, _ID, _Type, _SearchTerm, _Stu, 0, _Iff) -> [];
  preview_body(IndexTable, ID, ivk, SearchTerm, PrevStu, Limit, Iff) ->
      lists:reverse(preview_body_unique(IndexTable, ID, SearchTerm, PrevStu, Limit, Iff, []));
  preview_body(IndexTable, ID, iv_k, SearchTerm, {ID, Value} = Stu, Limit, Iff) ->
      Partial = case imem_if:read(IndexTable, Stu) of
          [#ddIndex{stu = {ID, Value}, lnk = Key} = Entry] ->
              case binary:match(Value, SearchTerm) =/= nomatch andalso Iff({Key, Value}) of
                  true -> [build_result_entry(Entry#ddIndex.stu, body_match, Key, Value)];
                  false -> []
              end;
          _ -> []
      end,
      case imem_if:next(IndexTable, Stu) of
          '$end_of_table' -> Partial;
          {ID, _NextValue} = NextStu ->
              Partial ++ preview_body(IndexTable, ID, iv_k, SearchTerm, NextStu, Limit - 1, Iff);
          _ -> Partial
      end;
  preview_body(IndexTable, ID, iv_kl, SearchTerm, {ID, Value} = Stu, Limit, Iff) ->
      Partial = case imem_if:read(IndexTable, Stu) of
          [#ddIndex{stu = {ID, Value}, lnk = KeyList} = Entry] ->
              case binary:match(Value, SearchTerm) =/= nomatch of
                  true -> preview_expand_kl(body_match, Entry#ddIndex.stu, KeyList, Value, Iff);
                  false -> []
              end;
          _ -> []
      end,
      case imem_if:next(IndexTable, Stu) of
          '$end_of_table' -> Partial;
          {ID, _NextValue} = NextStu ->
              Partial ++ preview_body(IndexTable, ID, iv_kl, SearchTerm, NextStu, Limit - 1, Iff);
          _ -> Partial
      end;
  preview_body(IndexTable, ID, iv_h, SearchTerm, {ID, Value} = Stu, Limit, Iff) ->
      Partial = case imem_if:read(IndexTable, Stu) of
          [#ddIndex{stu = {ID, Value}, lnk = Hash}] ->
              case binary:match(Value, SearchTerm) =/= nomatch of
                  true -> preview_expand_hash(body_match, IndexTable, ID, Hash, Value, ?SMALLEST_TERM, Iff);
                  false -> []
              end;
          _ -> []
      end,
      case imem_if:next(IndexTable, Stu) of
          '$end_of_table' -> Partial;
          {ID, _NextValue} = NextStu ->
              Partial ++ preview_body(IndexTable, ID, iv_h, SearchTerm, NextStu, Limit - 1, Iff);
          _ -> Partial
      end.
  
  -spec create_starting_stu(atom(), integer(), atom(), binary()) -> tuple().
  