Skip to content

Commit

Permalink
Merge pull request #19 from manukall/allow_options_in_search
Browse files Browse the repository at this point in the history
Allow options in search
  • Loading branch information
werbitzky authored Apr 4, 2017
2 parents d114283 + 61c8596 commit 50056c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Currently we can
* pass options to the JSON decoder used by Elastix ([poison](https://github.com/devinus/poison))
* optionally use shield for authentication ([shield](https://www.elastic.co/products/shield))
* optionally pass along custom headers for every request made to the elasticsearch server(s)s
* optionally pass along options to [HTTPoison](https://github.com/edgurgel/httpoison)

by setting the respective keys in your `config/config.exs`

Expand All @@ -137,7 +138,8 @@ config :elastix,
poison_options: [keys: :atoms],
shield: true,
username: "username",
password: "password"
password: "password",
httpoison_options: [hackney: [pool: :elastix_pool]]
```

The above for example will
Expand Down
5 changes: 5 additions & 0 deletions lib/elastix/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ defmodule Elastix.HTTP do
headers
end

options = Keyword.merge(default_httpoison_options(), options)
HTTPoison.Base.request(
__MODULE__,
method,
Expand All @@ -58,4 +59,8 @@ defmodule Elastix.HTTP do
defp poison_options do
Elastix.config(:poison_options, [])
end

defp default_httpoison_options do
Elastix.config(:httpoison_options, [])
end
end
4 changes: 2 additions & 2 deletions lib/elastix/search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ defmodule Elastix.Search do
end

@doc false
def search(elastic_url, index, types, data, query_params) do
def search(elastic_url, index, types, data, query_params, options \\ []) do
elastic_url <> make_path(index, types, query_params)
|> HTTP.post(Poison.encode!(data))
|> HTTP.post(Poison.encode!(data), options)
end

@doc false
Expand Down

0 comments on commit 50056c8

Please sign in to comment.