-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathscript_sort.sh
More file actions
executable file
·34 lines (32 loc) · 836 Bytes
/
Copy pathscript_sort.sh
File metadata and controls
executable file
·34 lines (32 loc) · 836 Bytes
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
#!/bin/bash
#
# Simple example of sorting using script
#
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"doc": {
"_timestamp" : {"enabled" : true, "index" : "analyzed", "store" : "yes"}
}
}
}'
curl -XPUT localhost:9200/test/doc/1 -d '{"foo": ["1"]}'
curl -XPUT localhost:9200/test/doc/2 -d '{"foo": ["2", "3"]}'
curl -XPUT localhost:9200/test/doc/3 -d '{"foo": ["3", "4", "5"]}'
curl -XPOST localhost:9200/test/_refresh
echo
curl "localhost:9200/test/doc/_search" -d '{
"sort": [
{
"_script": {
"script" : "doc[\"foo\"].values.size()",
"type" : "number"
}
}
]
}'
echo