anchor.diff:                      end;
                   Id ->
   				    %% Get specific user
  -					Query = "{\"size\" :100,\"query\" : {\"term\" : {\"username\":\"" ++ Id ++"\"}}}",
  -					case erlastic_search:search_json(#erls_params{},?INDEX, "user", Query) of 
  -						{error, {Code, Body}} -> 
  -							ErrorString = api_help:generate_error(Body, Code),
  -                            {{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  -						{ok, Json} ->
  -							ESId = lib_json:get_field(Json, "hits.hits[0]._id"),
  -							case erlastic_search:get_doc(?INDEX, "user", ESId) of
  -								{error, {Code1, Body1}} -> 
  -									ErrorString1 = api_help:generate_error(Body1, Code1),
  -									{{halt, Code1}, wrq:set_resp_body(ErrorString1, ReqData), State};
  -								{ok,JsonStruct} ->
  -									FinalJson = lib_json:get_and_add_id(JsonStruct),
  -									{FinalJson, ReqData, State} 
  -							end
  +					case erlastic_search:get_doc(?INDEX, "user", Id) of
  +						{error, {Code1, Body1}} -> 
  +							ErrorString1 = api_help:generate_error(Body1, Code1),
  +							{{halt, Code1}, wrq:set_resp_body(ErrorString1, ReqData), State};
  +						{ok,JsonStruct} ->
  +							FinalJson = lib_json:get_and_add_id(JsonStruct),
  +							{FinalJson, ReqData, State} 
   					end
               end;
           true ->                        
  
positive.code:     case api_help:is_search(ReqData) of
          false ->
  			{UserJson,_,_} = api_help:json_handler(ReqData, State),
  			UserName = lib_json:get_field(UserJson, "username"),
  			Query = "{\"size\" :100,\"query\" : {\"term\" : {\"username\":\"" ++ lib_json:to_string(UserName) ++"\"}}}", 
  			UserNameUnique = case erlastic_search:search_json(#erls_params{},?INDEX, "user", Query) of
  								 {error, {Code, Body}} -> 
  									 {Code,Body};
  								 {ok, Json} ->
  							   		lib_json:get_field(Json, "hits.total") == 0
  							 end,
  			case {api_help:do_only_fields_exist(UserJson,?ACCEPTEDFIELDSUSERS),UserNameUnique,UserName =/= undefined} of
  		  		{_,_,false} ->
  			  		{{halt,403}, wrq:set_resp_body("Username missing", ReqData), State};
  				{false,_,_} ->
  					{{halt,403}, wrq:set_resp_body("Unsupported field(s)", ReqData), State};
  				{true,false,_} ->
  					{{halt,409}, wrq:set_resp_body("Non unique username given", ReqData), State};
  				{true,{Code1,Body1},_} ->
  					ErrorString1 = api_help:generate_error(Body1, Code1),
  		            {{halt, Code1}, wrq:set_resp_body(ErrorString1, ReqData), State};
  				{true,true,_} ->
                      FieldsAdded = add_server_side_fields(UserJson),
  					case erlastic_search:index_doc(?INDEX, "user", FieldsAdded) of
  						{error, {Code2, Body2}} -> 
  							ErrorString2 = api_help:generate_error(Body2, Code2),
                      		{{halt, Code2}, wrq:set_resp_body(ErrorString2, ReqData), State};
  
negative.code: 		{false,false} ->
  			{{halt,403}, wrq:set_resp_body("Unsupported field(s)", ReqData), State};
  		{false,true} ->
  			Update = api_help:create_update(UserJson),
  			case api_help:update_doc(?INDEX, "user", Id, Update) of
  				{error, {Code, Body}} -> 
  					ErrorString = api_help:generate_error(Body, Code),
  					{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  				{ok, Json} ->
  					{true, wrq:set_resp_body(lib_json:encode(Json), ReqData), State}
  			end	
  	end.
  
  
  