anchor.diff:  %% Returns: JSON string that is updated with filter and the from size parameters
   %% @end
   filter_json(Json, From, Size, Sort) ->
  -    case lib_json:get_field(Json, "sort") of 
  -        undefined -> 
  -            UseSort = "\"" ++ Sort ++ "\"", 
  -            SortJson = Json;
  -        SortValue when is_binary(SortValue) -> 
  -            UseSort = "\"" ++ binary_to_list(SortValue) ++ "\"",
  -            SortJson = lib_json:rm_field(Json, "sort");
  -        SortValue -> 
  -            UseSort = SortValue,
  -            SortJson = lib_json:rm_field(Json, "sort")
  -    end,
  -    NewJson = string:sub_string(SortJson,1,string:len(SortJson)-1),
  -    "{\"from\" : "++From++
  -    ",\"size\" : "++Size++
  -    ",\"sort\" : " ++UseSort++
  -    ",\"query\" : {\"filtered\" : "++NewJson++
  -    ",\"filter\" : {\"bool\" : {\"must_not\" : {\"term\" : {\"private\" : \"true\"}}}}}}}".
  +	case lib_json:get_field(Json, "sort") of 
  +		undefined -> 
  +			UseSort = "\"" ++ Sort ++ "\"", 
  +			SortJson = Json;
  +		SortValue when is_binary(SortValue) -> 
  +			UseSort = "\"" ++ binary_to_list(SortValue) ++ "\"",
  +			SortJson = lib_json:rm_field(Json, "sort");
  +		SortValue -> 
  +			UseSort = SortValue,
  +			SortJson = lib_json:rm_field(Json, "sort")
  +	end,
  +	NewJson = string:sub_string(SortJson,1,string:len(SortJson)-1),
  +	"{\"from\" : "++From++
  +	",\"size\" : "++Size++
  +	",\"sort\" : " ++UseSort++
  +	",\"query\" : {\"filtered\" : "++NewJson++
  +	",\"filter\" : {\"bool\" : {\"must_not\" : {\"term\" : {\"private\" : \"true\"}}}}}}}".
  +
  
positive.code:     end,
      get_history(Rest, NrValues, lib_json:add_value(Acc,"history",IdAndDataJson)).
  
  %% @doc
  %% Function: get_streams/2
  %% Purpose: Gets the NrValues latest datapoints for each streamid that exists in list IdList
  %% Returns: JSON string that contains the data and streamid for each streamid in IdList
  %% @end
  get_streams([], Acc) ->
      "{\"streams\":[]}";
  get_streams(List, Acc) ->
      erlang:display(List),
      Json = "{\"filter\":{\"and\":[{\"ids\":{\"values\":"++List++"}},{\"bool\":{\"must_not\":{\"term\":{\"private\":\"true\"}}}}]}}",
      case erlastic_search:search_json(#erls_params{},?INDEX, "stream", Json) of
          {error,{Code, Body}} ->
              ErrorString = api_help:generate_error(Body, Code),
              JsonStruct = "{\"stream_id\":\""++Head++"\",\"data\":{\"error\": \""++ErrorString++"\"}";
          {ok,JsonStruct} ->
               "{\"streams\":"++lib_json:get_field(JsonStruct, "hits.hits")++"}"
      end,
  
      
  
  %% @doc
  %% Function: parse_datapoints/2
  
negative.code: %% @end
  -spec content_types_provided(ReqData::tuple(), State::string()) -> {list(), tuple(), string()}.
  content_types_provided(ReqData, State) ->
  		{[{"application/json", get_search}], ReqData, State}.
  
  
  %% @doc
  