-
Notifications
You must be signed in to change notification settings - Fork 93
/
mapping.exs
35 lines (30 loc) · 1.29 KB
/
mapping.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
# Run this example from console manually:
#
# $ mix run -r examples/mapping.exs
# # => curl -X PUT -d '{ "dsl": { "properties": { "mn_opts_": { "type": "nested", "properties": { "uk": { "type": "object", "properties": { "credentials": { "type": "object", "properties": { "available_from": { "type": "long" }, "buy": { "type": "object" }, "str": { "type": "object" } } } } } } }, "rev_history_": { "type": "object" } } } }' http://127.0.0.1:9200/bear_test
#
# Run this example from Elixir environment (`iex -S mix`):
#
# iex> Path.expand("examples/mapping.exs") |> Tirexs.load_file
#
Tirexs.DSL.define(fn() ->
import Tirexs.Mapping
index = [type: "dsl", index: "bear_test"]
mappings do
indexes "mn_opts_", [type: "nested"] do
indexes "uk", [type: "object"] do
indexes "credentials", [type: "object"] do
indexes "available_from", type: "long"
indexes "buy", type: "object"
indexes "str", type: "object"
end
end
end
indexes "rev_history_", type: "object"
end
# Below a couple of code lines which could be useful for debugging and getting actual JSON string
# url = Tirexs.HTTP.url(index[:index])
# json = JSX.prettify!(JSX.encode!(Tirexs.Mapping.to_resource_json(index)))
# IO.puts "\n# => curl -X PUT -d '#{json}' #{url}"
index end)