-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsubstr.sh
executable file
·33 lines (32 loc) · 950 Bytes
/
substr.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
#!/bin/bash
# Example of returning parts of the string
# Should be used in conjuntion with substr.mvel script that should be moved to config/scripts
#
curl -XDELETE "http://localhost:9200/test-idx?pretty"
curl -XPUT "http://localhost:9200/test-idx/doc/1?pretty&refresh" -d '{
"text": "This is a very large text string that has to be split in multiple parts!"
}'
curl -XGET "http://localhost:9200/test-idx/doc/_search?pretty" -d '{
"script_fields": {
"sub_test": {
"script": "substr",
"params": {
"field": "text",
"offset": 0,
"len": 10
}
}
}
}'
curl -XGET "http://localhost:9200/test-idx/doc/_search?pretty" -d '{
"script_fields": {
"sub_test": {
"script": "substr",
"params": {
"field": "text",
"offset": 70,
"len": 10
}
}
}
}'