# NOT RUN {
# connection setup
(x <- connect())
# create
body1 <- '{
"description" : "do a thing",
"version" : 123,
"processors" : [
{
"set" : {
"field": "foo",
"value": "bar"
}
}
]
}'
body2 <- '{
"description" : "do another thing",
"processors" : [
{
"set" : {
"field": "stuff",
"value": "things"
}
}
]
}'
pipeline_create(x, id = 'foo', body = body1)
pipeline_create(x, id = 'bar', body = body2)
# get
pipeline_get(x, id = 'foo')
pipeline_get(x, id = 'bar')
pipeline_get(x, id = 'foo', filter_path = "*.version")
pipeline_get(x, id = c('foo', 'bar')) # get >1
# delete
pipeline_delete(x, id = 'foo')
# simulate
## with pipeline included
body <- '{
"pipeline" : {
"description" : "do another thing",
"processors" : [
{
"set" : {
"field": "stuff",
"value": "things"
}
}
]
},
"docs" : [
{ "_source": {"foo": "bar"} },
{ "_source": {"foo": "world"} }
]
}'
pipeline_simulate(x, body)
## referencing existing pipeline
body <- '{
"docs" : [
{ "_source": {"foo": "bar"} },
{ "_source": {"foo": "world"} }
]
}'
pipeline_simulate(x, body, id = "foo")
# attchments - Note: you need the attachment plugin for this, see above
body1 <- '{
"description" : "do a thing",
"version" : 123,
"processors" : [
{
"attachment" : {
"field" : "data"
}
}
]
}'
pipeline_create(x, "baz", body1)
body_attach <- '{
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}'
if (!index_exists(x, "boomarang")) index_create(x, "boomarang")
docs_create(x, 'boomarang', id = 1, body = list(title = "New title"))
pipeline_attachment(x, "boomarang", "1", "baz", body_attach)
pipeline_get(x, id = 'baz')
# }
Run the code above in your browser using DataLab