-
Notifications
You must be signed in to change notification settings - Fork 2
/
percolate.sh
executable file
·59 lines (43 loc) · 1.26 KB
/
percolate.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
#!/bin/sh
# This shows it is feasible to use percolation to
# test if a created or updated record matches a query.
# This can be used to insert/move the updated record in
# an existing search result list.
alias curl='./curl_wrapper.rb'
curl -s -XDELETE localhost:9200/test > /dev/null
curl -s -XDELETE localhost:9200/_percolator > /dev/null
# Setup
curl -XPOST localhost:9200/test
curl -XPOST localhost:9200/_percolator
curl -XPUT localhost:9200/_percolator/test/_mapping -d '{
"test": {
"_timestamp": { "enabled": true },
"_ttl": { "enabled": true }
}
}'
curl -XGET localhost:9200/_percolator/_mapping?pretty=true
# 2 requests to check if the doc matches the query
curl -XPUT 'localhost:9200/_percolator/test/kuku?ttl=1000&refresh=true' -d '{
"query": {
"term": {
"field1": "value1"
}
}
}'
curl -XGET localhost:9200/test/type1/_percolate -d '{
"doc" : {
"field1" : "value1"
},
"query": {
"ids": {
"type": "test",
"values": ["kuku"]
}
}
}'
# Confirm percolator query is deleted (could explicitly delete query)
curl localhost:9200/_percolator/test/kuku
sleep 60
curl localhost:9200/_percolator/test/kuku
curl -s -XDELETE localhost:9200/test > /dev/null
curl -s -XDELETE localhost:9200/_percolator > /dev/null