anchor.diff:  %% @end
   -spec create_query(Function::string(), Streams::string(), TimestampFrom::string()) -> {string()}.
   create_query(Function, Streams, TimestampFrom) ->
  -	%size to be passed as a variable??
  +	%size to be passed as a variable?? but it will not work in the terms facets query...
   	Query = lib_json:set_attrs(
   		  [{size, 100},
   		   {"query", "{}"},
  
positive.code: 
  
  %% @doc
  %% Function: process_search/3
  %% Purpose: Does search for Datapoints for either search done with POST or GET
  %% Returns: {true, ReqData, State} || {{error, Reason}, ReqData, State}
  
  %the POST range query should be structed as follows:
  %	curl -XPOST http://localhost:8000/streams/1/data/_search -d '{
  %		"size" : 100,
  %		query:{
  % 		   "filtered" : {
  % 		       "query" : {
  %  		          "term" : { "streamid" : Id }
  %  		      }, "filter" : {  "range" : {    "timestamp" : {"gte" : timestampFromValue,"lte" : timestampToValue}}}}
  %		 },"sort" : [{"timestamp" : {"order" : "asc"}}]  }'
  %the GET range query should be structed as follows:
  %	curl -XGET http://localhost:8000/streams/Id/data/_search    --   to return all the datapoints of the current stream
  %or	curl -XGET http://localhost:8000/streams/Id/data/_search\?timestampFrom\=timestampFromValue\&timestampTo\=timestampToValue    --   for range query
  %or 	curl -XGET http://localhost:8000/streams/Id/data/_search\?timestampFrom\=timestampFromValue   --   for lower bounded only range qquery
  %% @end
  -spec process_search(ReqData::tuple(), State::string(), term()) ->
  		{list(), tuple(), string()}.
  process_search(ReqData, State, post) ->
  		{Json,_,_} = api_help:json_handler(ReqData,State),
  		case erlastic_search:search_json(#erls_params{},?INDEX, "datapoint", Json) of
  				{error, Reason} -> {{error,Reason}, wrq:set_resp_body("{\"error\":\""++ atom_to_list(Reason) ++ "\"}", ReqData), State};
  				{ok,JsonStruct} ->
  						       FinalJson = lib_json:get_list_and_add_id(JsonStruct),
  						       {true,wrq:set_resp_body(lib_json:encode(FinalJson),ReqData),State}
  		end.
  
  
  %% @doc
  %% Function: generate_date/2
  %% Purpose: Used to create a date valid in ES
  %%          from the input which should be the list
  
negative.code: 						  	 {"facets.statistics", "{}"},
  						  	 {"facets.statistics.statistical", "{}"},
  						  	 {"facets.statistics.statistical.script", '(Long) _source.value'}]; %I have to get the value here in another way
  			_ -> %		["aggregate", "min" "max" "total(==sum)" ] ->		can also support custom calculations like *,+,-,/, ^(prob)
  					% as above
  					Facet = [{"facets", "{}"},
  							{"facets.tag_price_stats", "{}"},
  