-
Notifications
You must be signed in to change notification settings - Fork 9
/
geo_shape.sh
executable file
·77 lines (75 loc) · 1.67 KB
/
geo_shape.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# Example of sorting on multiple geo_points
#
curl -XDELETE 'localhost:9200/geotest'
echo
curl -XPOST 'localhost:9200/geotest' -d'{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"doc": {
"properties": {
"name": {
"type": "string"
},
"my_shape": {
"type": "geo_shape"
}
}
}
}
}
'
echo
curl -XPOST 'localhost:9200/geotest/doc/1' -d '{
"name": "foo",
"my_shape": {
"type" : "envelope",
"coordinates" : [[-45.0, 45.0], [45.0, -45.0]]
}
}'
echo
curl -XPOST 'localhost:9200/geotest/doc/2' -d '{
"name": "foo",
"my_shape": {
"type" : "polygon",
"coordinates" : [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}
}'
echo
curl -XPOST 'localhost:9200/geotest/doc/3' -d '{
"name": "foo",
"my_shape": {
"type": "Point",
"coordinates": [13.400544, 52.530286]
}
}'
echo
curl -XPOST 'localhost:9200/geotest/_refresh'
echo
curl 'localhost:9200/geotest/doc/_search?pretty' -d'{
"query":{
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_shape": {
"my_shape": {
"shape": {
"type": "envelope",
"coordinates" : [[13.0, 53.0], [14.0, 52.0]]
},
"relation": "within"
}
}
}
}
}
}
'