tsloughter / erlastic_search

An Erlang app for communicating with Elastic Search's rest interface.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for bulk update, please ?

arkanmgerges opened this issue · comments

Hi, can you make the app to bulk update the documents please ? instead of sending a lot of requests to update the document, it would be nice to have bulk update.

Thanks

Looking at the common tests - this appears to be implemented via erlastic_search:bulk_index_docs/2 :

bulk_index_id(Config) ->
IndexName = ?config(index_name, Config),
Id = create_random_name(<<"es_id_">>),
Doc = {<<"how">>, <<"you_doing">>}, %% in Joey Tribbiani voice
Items = [{IndexName, <<"type_1">>, Id, [Doc]}],
{ok, _} = erlastic_search:bulk_index_docs(#erls_params{}, Items),
{ok, _} = erlastic_search:flush_index(IndexName),
{ok, Resp} = erlastic_search:search(IndexName, <<"how:you_doing">>),
{<<"hits">>, Hits} = lists:keyfind(<<"hits">>, 1, Resp),
{<<"hits">>, Hits1} = lists:keyfind(<<"hits">>, 1, Hits),
F = fun(Item) ->
{<<"_id">>, AId} = lists:keyfind(<<"_id">>, 1, Item),
AId == Id
end,
[_] = lists:filter(F, Hits1).

Let me know if this is still an issue - if I don't hear back from you, I'll close this issue out.