Skip to content

Commit f25c398

Browse files
Updated to not pass the document index when creating
1 parent 066900b commit f25c398

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

test/integration/skill_controller_search_test.exs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
defmodule SkillControllerSearchIntegrationTest do
22
use ExUnit.Case, async: true
33
alias CodeCorps.ElasticSearchHelper
4-
alias Elastix.Document
54

65
@test_url Application.get_env(:code_corps, :elasticsearch_url)
76
@test_index Application.get_env(:code_corps, :elasticsearch_index)
@@ -30,21 +29,9 @@ defmodule SkillControllerSearchIntegrationTest do
3029
end
3130

3231
def init do
33-
data = %{
34-
title: "Elixir"
35-
}
36-
Document.index @test_url, @test_index, @type_value, 1, data, [refresh: true]
37-
data = %{
38-
title: "Ruby"
39-
}
40-
Document.index @test_url, @test_index, @type_value, 2, data, [refresh: true]
41-
data = %{
42-
title: "Rails"
43-
}
44-
Document.index @test_url, @test_index, @type_value, 3, data, [refresh: true]
45-
data = %{
46-
title: "CSS"
47-
}
48-
Document.index @test_url, @test_index, @type_value, 4, data, [refresh: true]
32+
ElasticSearchHelper.add_document(@test_url, @test_index, @type_value, %{title: "Elixir"}, [refresh: true])
33+
ElasticSearchHelper.add_document(@test_url, @test_index, @type_value, %{title: "Ruby"}, [refresh: true])
34+
ElasticSearchHelper.add_document(@test_url, @test_index, @type_value, %{title: "Rails"}, [refresh: true])
35+
ElasticSearchHelper.add_document(@test_url, @test_index, @type_value, %{title: "CSS"}, [refresh: true])
4936
end
5037
end

web/helpers/elastic_search_helper.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule CodeCorps.ElasticSearchHelper do
22
alias Elastix.Search
33
alias Elastix.Index
4+
alias Elastix.Document
45

56
@test_url Application.get_env(:code_corps, :elasticsearch_url)
67
@test_index Application.get_env(:code_corps, :elasticsearch_index)
@@ -14,6 +15,10 @@ defmodule CodeCorps.ElasticSearchHelper do
1415
Index.settings(url, "#{index}/_mapping/#{type}", field_filter)
1516
end
1617

18+
def add_document(url, index, type, data, query) do
19+
Document.index_new(url, index, type, data, query)
20+
end
21+
1722
def search(url, index, search_query) do
1823
data = %{
1924
query: %{

0 commit comments

Comments
 (0)