anchor.diff:  	Type  = lib_json:get_field(Stream, "type"),
   	Accuracy  = lib_json:get_field(Stream, "accuracy"),
   	Weight = scoring:calc([Name, Description, Min_val, Max_val, Tags, Type, Accuracy]),
  -	Result ="{
  -		\"name\":\"" ++ undefined_to_string(Name)++"\",
  -		\"description\":\"" ++ undefined_to_string(Description)++"\",
  -		\"min_value\":\"" ++ undefined_to_string(Min_val)++"\",
  -		\"max_value\":\"" ++ undefined_to_string(Max_val)++"\",
  -		\"tags\":\"" ++ undefined_to_string(Tags)++"\",
  -		\"type\":\"" ++ undefined_to_string(Type)++"\",
  -		\"accuracy\":\"" ++ undefined_to_string(Accuracy)++"\"
  -		}",
  +        Result = lib_json:set_attrs([{name, Name},
  +				     {description, Description},
  +				     {min_value, Min_val},
  +				     {max_value, Max_val},
  +				     {tags, Tags},
  +				     {type, Type},
  +				     {accuracy, Accuracy}
  +				    ]),
   	{Weight, Result}.
  -
  -
  -%% @doc
  -%% Returns an empty string if it was "undefined", else it returns the string itself.
  -%% @end
  --spec undefined_to_string(Text::attr()) -> string().
  -undefined_to_string(Text) ->
  -	case Text of
  -		undefined ->
  -			"";
  -		_ ->
  -			lib_json:to_string(Text)
  -	end.
  -
  -
  -%% @doc
  -%% Returns an empty string if it was "undefined", else it returns the string itself. Concerted to binary
  -%% @end
  --spec binary_undefined_to_string(Text::attr()) -> string().
  -binary_undefined_to_string(Text) ->
  -	case Text of
  -		undefined ->
  -			<<"">>;
  -		_ ->
  -			Text
  -	end.
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% Should be moved to own module later
  
positive.code: 		undefined ->
  			{error, no_model};
  		_ ->
  			Suggestion = "{
  				\"resource_id\" : \"" ++ undefined_to_string(ResourceId) ++ "\",
  				\"suggest\" : {
  					\"input\" : [ \"" ++ undefined_to_string(Model) ++ "\" ], 
  					\"output\" : \"" ++ get_timestamp() ++ "\",
  					\"payload\" : { 
  						\"manufacturer\" : \"" ++ undefined_to_string(Manufacturer) ++ "\",
  						\"tags\" : \"" ++ undefined_to_string(Tags) ++ "\",
  						\"polling_freq\" : \"" ++ undefined_to_string(Polling_freq) ++ "\"
  					},
  					\"weight\" : " ++ integer_to_list(Weight) ++ "
  				}				
  				}",
  			case erlastic_search:index_doc(?INDEX, "suggestion", Suggestion) of 
  				{error, _Reason} -> erlang:display("Suggestion not saved ");
  				{ok, _} -> 	ok
  
negative.code: 	TS = {_MSec,_Sec,Micro} = os:timestamp(),
  	{{Year,Month,Day},{Hour,Minute,Second}} = calendar:now_to_universal_time(TS),
  	Mstr = element(Month,{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}),
  	binary:list_to_bin(io_lib:format("~2w ~s ~4w ~2w:~2..0w:~2..0w.~6..0w", [Day,Mstr,Year,Hour,Minute,Second,Micro])).
  
  
  
  
  