Skip to content

Commit 6e0aafc

Browse files
added some convenience functions
1 parent 0ed91f6 commit 6e0aafc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

web/helpers/elastic_search_helper.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ defmodule CodeCorps.ElasticSearchHelper do
1212
Index.settings(url, "#{index}/_mapping/#{type}", field_filter)
1313
end
1414

15+
def add_documents(url, index, type, documents) when is_list(documents) do
16+
add_documents(url, index, type, documents, [])
17+
end
18+
1519
def add_documents(url, index, type, documents, query) when is_list(documents) do
1620
Enum.each(documents, fn(x) -> add_document(url, index, type, to_map(type, x), query) end)
1721
end
1822

23+
def add_document(url, index, type, data) do
24+
add_document(url, index, type, data, [])
25+
end
26+
1927
def add_document(url, index, type, data, query) do
2028
Document.index_new(url, index, type, data, query)
2129
end

0 commit comments

Comments
 (0)