anchor.diff:      end,
       {Json,_,_} = api_help:json_handler(ReqData,State),
       FilteredJson = filter_json(Json, From, Size, Sort),
  +    erlang:display(lib_json:to_string(FilteredJson)),
       case erlastic_search:search_json(#erls_params{},?INDEX, "stream", FilteredJson) of % Maybe wanna take more
               {error, Reason1} ->
                   StreamSearch = {error, Reason1};
               {ok,List1} ->
  -			case lib_json:get_field(FilteredJson, "query.filtered.query.query_string.query") of
  -				undefined ->
  -					erlang:display("No query string text");
  -				QueryString ->
  -					erlastic_search:index_doc(?INDEX,"search_query","{\"search_suggest\":{\"input\":[\""++ lib_json:to_string(QueryString) ++"\"],\"weight\":1}}")
  -			end,
  -			StreamSearch = lib_json:encode(List1) % May need to convert
  +            case lib_json:get_field(FilteredJson, "query.filtered.query.query_string.query") of
  +                undefined ->
  +                    erlang:display("No query string text");
  +                QueryString ->
  +                    erlastic_search:index_doc(?INDEX,"search_query","{\"search_suggest\":{\"input\":[\""++ lib_json:to_string(QueryString) ++"\"],\"weight\":1}}")
  +            end,
  +            StreamSearch = lib_json:encode(List1) % May need to convert
       end,
       case erlastic_search:search_json(#erls_params{},?INDEX, "user", lib_json:rm_field(FilteredJson, "sort")) of % Maybe wanna take more
               {error, Reason2} ->
                       UserSearch = {error, Reason2};
               {ok,List2} -> 
  -			UserSearch = lib_json:encode(List2) % May need to convert
  +            UserSearch = lib_json:encode(List2) % May need to convert
        end,
  -	% check search-results for error
  -	case StreamSearch of
  -		{error, {Body, Code}} ->
  -		ErrorString = api_help:generate_error(Body, Code),
  -		{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  -		_ -> 
  -		case UserSearch of
  -		  {error, {Body, Code}} ->
  -			ErrorString = api_help:generate_error(Body, Code),
  -			{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  -		  _ ->
  -				SearchResults = "{\"streams\":"++ StreamSearch ++", \"users\":"++ UserSearch ++"}",
  -				{true,wrq:set_resp_body(SearchResults,ReqData),State}
  -		end
  -	end.
  +    % check search-results for error
  +    case StreamSearch of
  +        {error, {Body, Code}} ->
  +        ErrorString = api_help:generate_error(Body, Code),
  +        {{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  +        _ -> 
  +        case UserSearch of
  +          {error, {Body, Code}} ->
  +            ErrorString = api_help:generate_error(Body, Code),
  +            {{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  +          _ ->
  +                SearchResults = "{\"streams\":"++ StreamSearch ++", \"users\":"++ UserSearch ++"}",
  +                {true,wrq:set_resp_body(SearchResults,ReqData),State}
  +        end
  +    end.
   %% GROUPS ARE NOT IMPLEMENTED
   %%         case erlastic_search:search_json(#erls_params{},?INDEX, "group", FilteredJson) of % Maybe wanna take more
   %%                 {error,Reason} -> {{halt,Reason}, ReqData, State};
  
positive.code: %% @end
  -spec init([]) -> {ok, undefined}.
  init([]) -> 
  		{ok, undefined}.
  
  
  
  
negative.code: %% @end
  -spec allowed_methods(ReqData::tuple(), State::string()) -> {list(), tuple(), string()}.
  allowed_methods(ReqData, State) ->
          case api_help:parse_path(wrq:path(ReqData)) of                
                  [{"_search"}] ->
                          {['POST','GET'], ReqData, State};
                  [{"_history"}] ->
                          {['POST','GET'], ReqData, State};
                  [error] ->
                          {['POST','GET'], ReqData, State}
          end.
  
  
  
  
  