Skip to content

Commit

Permalink
Merge pull request #42 from PrasadBonthu/master
Browse files Browse the repository at this point in the history
Added scroll support
  • Loading branch information
tsloughter committed Aug 19, 2016
2 parents bf90f00 + 90431cf commit 3c01b35
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/erlastic_search.erl
Expand Up @@ -32,6 +32,8 @@
,search/3
,search/5
,search_limit/4
,search_scroll/4
,search_scroll/1
,get_doc/3
,get_doc/4
,flush_index/1
Expand Down Expand Up @@ -230,6 +232,23 @@ search(Index, Type, Query) ->
search_limit(Index, Type, Query, Limit) when is_integer(Limit) ->
search(#erls_params{}, Index, Type, Query, [{<<"size">>, integer_to_list(Limit)}]).

%%--------------------------------------------------------------------
%% @doc
%% search_scroll/4 -- Takes the index, type name and search query
%% sends it to the Elasticsearch server specified in Params.
%% Returns search results along with scroll id which can be passed
%% to search_scroll/1 to get next set of search results
%% @end
%%--------------------------------------------------------------------
-spec search_scroll(binary() | list(), binary(), erlastic_json() | binary(), list()) -> {ok, erlastic_success_result()} | {error, any()}.
search_scroll(Index, Type, Query, Timeout) ->
search(#erls_params{}, Index, Type, Query, [{<<"scroll">>, list_to_binary(Timeout)}]).

-spec search_scroll(erlastic_json() | binary()) -> {ok, erlastic_success_result()} | {error, any()}.
search_scroll(Query) ->
Params = #erls_params{},
erls_resource:post(Params, filename:join([<<"_search">>, <<"scroll">>]), [], [], erls_json:encode(Query), Params#erls_params.http_client_options).

-spec search(#erls_params{}, list() | binary(), list() | binary(), erlastic_json() | binary(), list()) -> {ok, erlastic_success_result()} | {error, any()}.
search(Params, Index, Type, Query, Opts) when is_binary(Query) ->
erls_resource:get(Params, filename:join([commas(Index), Type, <<"_search">>]), [], [{<<"q">>, Query}]++Opts, Params#erls_params.http_client_options);
Expand Down

0 comments on commit 3c01b35

Please sign in to comment.