# NOT RUN {
# typical usage
## create an index first
index_delete("myindex")
mapping <- '{
"mappings": {
"mytype": {
"properties": {
"message": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
}
}'
index_create("myindex", body = mapping)
## register a percolator
perc_body = '{
"query" : {
"match" : {
"message" : "bonsai tree"
}
}
}'
percolate_register(index = "myindex", id = 1, body = perc_body)
## register another
perc_body2 <- '{
"query" : {
"match" : {
"name" : "jane doe"
}
}
}'
percolate_register(index = "myindex", id = 2, body = perc_body2)
## match a document to a percolator
doc <- '{
"doc" : {
"message" : "A new bonsai tree in the office"
}
}'
percolate_match(index = "myindex", type = "mytype", body = doc, config = verbose())
## List percolators - for an index, no type, can't do across indices
percolate_list(index = "myindex")$hits$hits
## Percolate counter
percolate_count(index = "myindex", type = "mytype", body = doc)$total
## delete a percolator
percolate_delete(index = "myindex", id = 2)
# multi percolate
## not working yet
# }
Run the code above in your browser using DataLab