forked from elastic/elasticsearch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search Templates: Add render endpoint for rendering templates
This commit adds a render endpoint to allow rendering of templates. ```` POST /_render/template '{ "template": { "query": { "{{foo}}": {} }, "size": "{{my_{{}}size}}" }, "params": { "foo": "match_all", "my_size": 10} }' ```` Will render ```` { "template" : { "query" : { "match_all" : {} }, "size" : 10 } } ```` Closes elastic#6821
- Loading branch information
Showing
5 changed files
with
99 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"render_template": { | ||
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html", | ||
"methods": ["GET", "POST"], | ||
"url": { | ||
"path": "/_render/template", | ||
"paths": [ "/_render/template" ], | ||
"parts": { | ||
"id": { | ||
"type" : "string", | ||
"description" : "Template ID", | ||
"required" : true | ||
} | ||
} | ||
}, | ||
"body": { | ||
"description": "The search definition template and its params" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
"Render Template": | ||
|
||
- do: | ||
render_template: | ||
body: { "template": { "query": { "{{foo}}": {}}, "size": "{{my_size}}" }, "params": { "foo": "match_all", "my_size": 10} } | ||
- match: { "template": { "query": { "match_all": {} }, "size": "10"} } | ||
|
||
- do: | ||
put_template: | ||
id: "1" | ||
body: { "template": { "query": { "{{foo}}": {}}, "size": "{{my_size}}" } } | ||
- match: { _id: "1" } | ||
|
||
- do: | ||
render_template: | ||
body: { "template": { "id" : 1 }, "params": { "foo": "match_all", "my_size": 10} } | ||
- match: { "template": { "query": { "match_all": {} }, "size": "10"} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters