Skip to content

Commit 95bda41

Browse files
Added match all function
1 parent 40c7a14 commit 95bda41

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/integration/skill_controller_search_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ defmodule SkillControllerSearchIntegrationTest do
3838
assert results == []
3939
end
4040

41+
test "match all entries" do
42+
results = ElasticSearchHelper.match_all(@test_url, @test_index, "title")
43+
assert results -- ["Elixir", "Ruby", "Rails", "CSS"] == []
44+
end
45+
4146
def init do
4247
ElasticSearchHelper.add_documents(@test_url, @test_index, @type_value, ["Elixir", "Ruby", "Rails", "CSS"], [refresh: true])
4348
end

web/helpers/elastic_search_helper.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ defmodule CodeCorps.ElasticSearchHelper do
3737
Search.search(url, index, [], data) |> process_response(type)
3838
end
3939

40+
def match_all(url, index, type) do
41+
data = %{
42+
query: %{
43+
match_all: %{}
44+
}
45+
}
46+
Search.search(url, index, [], data) |> process_response(type)
47+
end
48+
4049
def process_response(%HTTPoison.Response{status_code: 200} = response, type) do
4150
response.body["hits"]["hits"] |> Enum.map(fn(x) -> x["_source"][type] end)
4251
end

0 commit comments

Comments
 (0)