-
Notifications
You must be signed in to change notification settings - Fork 9
/
disable_dynamic.sh
executable file
·56 lines (56 loc) · 1.4 KB
/
disable_dynamic.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
# This script shows how to disable dynamic mapping on a part of the object
# See http://stackoverflow.com/questions/17595129/elasticsearch-index-only-part-of-the-object
#
curl -XDELETE localhost:9200/test-idx
echo
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"doc": {
"properties": {
"record": {
"type": "object",
"properties": {
"city": {"type": "string"}
},
"dynamic": false
}
}
}
}
}'
echo
curl -XPUT localhost:9200/test-idx/doc/1 -d '{
"record": {
"city": "London",
"contact": "Some person name"
}
}'
echo
curl -XPUT localhost:9200/test-idx/doc/2 -d '{
"record": {
"city": "London",
"contact": { "phone": "some-phone-number", "name": "Other person'\''s name" }
},
"foo": "bar"
}'
echo
curl -XPUT localhost:9200/test-idx/doc/3 -d '{
"record": {
"city": "Oslo",
"headquarters": { "phone": "some-other-phone-number", "address": "some address" }
}
}'
echo
curl -XPOST localhost:9200/test-idx/_refresh
echo
curl "localhost:9200/test-idx/doc/_search?q=city:London&pretty"
echo
curl "localhost:9200/test-idx/doc/_mapping?pretty"