New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dedicated /_search/template endpoint for query templates #5353
Conversation
} | ||
}, | ||
"body": { | ||
"description": "The search definiation template" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo :)
I like it a lot! I think it looks pretty cool left some minor comments |
updated the PR based on your comments |
In order to simplify query template execution an own endpoint has been added Closes elastic#5353
"size" : {{mySize}} | ||
}, | ||
"params" : { | ||
"myField" : "foo", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have more reasonable names / values here maybe use an example that is more realistic like filter for a username or so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also suggest that we use my_value
which is less javaish?
a small amount of comments but LGTM !! |
} | ||
} | ||
------------------------------------------ | ||
|
||
|
||
For more information on how Mustache templating and what kind of templating you | ||
can do with it check out the [online |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect asciidoc link syntax here. Use: http://foo.com[Name]
I'd love to see some examples of more complicated templates, including mustache sections, use of arrays etc. Also, is the automatic html encoding of output turned off? |
hrm... {
"template" : {
"query": { "filtered" : {
"query" : { "match_all" : {} },
"filter" : { "owner" : "{{user}}" }
},
"aggs" : {
{{#aggs}}
"{{.}}" : { "terms" : { "field" : "{{.}}" } }
{{/aggs}}
}
},
"params" : {
"user" : "kimchy",
"aggs" : [ "category_id", "sub_category_id" ]
}
} something like this will not produce valid JSON, as you cannot check for the last element of an array with mustache, thanks to logicless template... need to think about this in order to solve it nicely, makes mustache somewhat limited here for our needs... |
i do wonder if mustache is the right answer here... You can certainly make it do the right thing, but I wonder how easy it will be for the user to write. |
it's just a scripting engine so you can plug in whatever produces a string? |
yeah, but i'm thinking more of the existing dsl with some added operators... not sure. need to play with it a bit |
OK I've worked through various non-trivial examples of templating using mustache, and added a number of worked examples to the docs page: See spinscale#2 There are some things (conditional clauses) which can't be expressed using the JSON form of templates, but can be expressed as strings. I've included an example in the PR. One thing that needs to be fixed is the
|
In order to simplify query template execution an own endpoint has been added Closes elastic#5353
LGTM lets push this @spinscale |
I've opened the escaping bug as a separate issue #5473 |
In order to simplify query template execution an own endpoint has been added Closes #5353
In order to simplify query template execution an own endpoint has been added
Open question: Should the JAVA APIs change as well?