summaryrefslogtreecommitdiff
path: root/modules/lang-mustache/src/main
AgeCommit message (Collapse)Author
2017-07-03Remove QueryParseContext (#25486)Christoph Büscher
QueryParseContext is currently only used as a wrapper for an XContentParser, so this change removes it entirely and changes the appropriate APIs that use it so far to only accept a parser instead.
2017-06-09Scripting: Change keys for inline/stored scripts to source/id (#25127)Ryan Ernst
This commit adds back "id" as the key within a script to specify a stored script (which with file scripts now gone is no longer ambiguous). It also adds "source" as a replacement for "code". This is in an attempt to normalize how scripts are specified across both put stored scripts and script usages, including search template requests. This also deprecates the old inline/stored keys.
2017-06-07Generate Painless Factory for Creating Script Instances (#25120)Jack Conradson
2017-06-05Fixed NPEs caused by requests without content. (#23497)Alex Benusovich
REST handlers that require a body will throw an an ElasticsearchParseException "request body required". REST handlers that require a body OR source param will throw an ElasticsearchParseException "request body or source param required". Replaced asserts in BulkRequest parsing code with a more descriptive IllegalArgumentException if the line contains an empty object. Updated bulk REST test to verify an empty action line is rejected properly. Updated BulkRequestTests with randomized testing for an empty action line. Used try-with-resouces for XContentParser in AbstractBulkByQueryRestHandler.
2017-06-02Scripting: Convert CompiledTemplate to a ScriptContext (#25032)Ryan Ernst
This commit creates TemplateScript and associated classes so that templates no longer need a special ScriptService.compileTemplate method. The execute() method is equivalent to the old run() method. relates #20426
2017-06-02Adds nodes usage API to monitor usages of actions (#24169)Colin Goodheart-Smithe
* Adds nodes usage API to monitor usages of actions The nodes usage API has 2 main endpoints /_nodes/usage and /_nodes/{nodeIds}/usage return the usage statistics for all nodes and the specified node(s) respectively. At the moment only one type of usage statistics is available, the REST actions usage. This records the number of times each REST action class is called and when the nodes usage api is called will return a map of rest action class name to long representing the number of times each of the action classes has been called. Still to do: * [x] Create usage service to store usage statistics * [x] Record usage in REST layer * [x] Add Transport Actions * [x] Add REST Actions * [x] Tests * [x] Documentation * Rafactors UsageService so counts are done by the handlers * Fixing up docs tests * Adds a name to all rest actions * Addresses review comments
2017-06-01Scripting: Add optional context parameter to put stored script requests (#25014)Ryan Ernst
This commit adds an optional `context` url parameter to the put stored script request. When a context is specified, the script is compiled against that context before storing, as a validation the script will work when used in that context.
2017-05-26Remove the need for _UNRELEASED suffix in versions (#24798)Nik Everett
Removes the need for the `_UNRELEASED` suffix on versions by detecting if a version should be unreleased or not based on the versions around it. This should make it simpler to automate the task of adding a new version label.
2017-05-26Scripting: Rename CompiledType to FactoryType in ScriptContext (#24897)Ryan Ernst
This commit renames the concept of the "compiled type" to a "factory type", along with all implementations of this class to be named Factory. This brings it inline with the classes purpose.
2017-05-25Scripting: Make contexts available to ScriptEngine construction (#24896)Ryan Ernst
This commit adds collection of all contexts to the parameters of getScriptEngine. This will allow script engines like painless to precache extra information about the contexts.
2017-05-25Scripting: Move context definitions to instance type classes (#24883)Ryan Ernst
This is a simple refactoring to move the context definitions into the type that they use. While we have multiple context names for the same class at the moment, this will eventually become one ScriptContext per instance type, so the pattern of a static member on the interface called CONTEXT can be used. This commit also moves the consolidated list of contexts provided by core ES into ScriptModule.
2017-05-24Scripting: Make ScriptEngine.compile generic on the script context (#24873)Ryan Ernst
This commit changes the compile method of ScriptEngine to be generic in the same way it is on ScriptService. This moves the shim of handling the two existing context classes into each script engine, so that each engine can be worked on independently to convert to real handling of contexts.
2017-05-24Scripting: Add instance and compiled classes to script contexts (#24868)Ryan Ernst
This commit modifies the compile method of ScriptService to be context aware. The ScriptContext is now a generic class which contains both the instance type and compiled type for a script. Instance type may be stateful (for example, pre loading field information for the index a script will execute on, like in expressions), while the compiled type is stateless and used to construct instance type instances. This change is only a first step to cutover ScriptService to the new paradigm. It only converts callers to the script service, and has a small shim to wrap compilation from the script engines to support the current two fixed instance types, SearchScript and ExecutableScript.
2017-05-24Scripting: Add default implementation of close() for ScriptEngine (#24851)Ryan Ernst
Since groovy was removed, we no longer have any ScriptEngines with resources to release. We may want to keep the option open for a script engine to close resources, but this would not be common. This commit adds a default implementation to ScriptEngine for `close()` to reduce the boiler plate that must be added for a ScriptEngine implementation.
2017-05-22Scripting: Simplify ScriptContext (#24818)Ryan Ernst
As we work towards contexts implying the return type of compilation, we first need ScriptContext to not be an enum. This commit removes the Standard enum and Plugin subclass of ScriptContext.
2017-05-20Scripting: Remove "inline script enabled" on script engines (#24815)Ryan Ernst
ScriptEngine implementations have an overridable method to indicate they are safe to use as inline scripts. Since groovy was removed fro 6.0, there are no longer any implementations which used the default false value. Furthermore, the value was not actually read anywhere. This commit removes the method. The ScriptEngineRegistry was also no longer necessary as it only was used to build a map from language to engine.
2017-05-17Scripting: Remove file scripts (#24627)Ryan Ernst
This commit removes file scripts, which were deprecated in 5.5. closes #21798
2017-05-15Scripts: Convert template script engines to return String instead of ↵Ryan Ernst
BytesReference (#24447) Template script engines (mustache, the only one) currently return a BytesReference that users must know is utf8 encoded. This commit modifies all callers and mustache to have the template engine return String. This is much simpler, and does not require decoding in order to use (for example, in ingest).
2017-05-11Removed deprecated template query.Martijn van Groningen
Relates to #19390
2017-05-10Rewrite multi search template api to delegate to multi search api instead of ↵Martijn van Groningen
to search template api. The max concurrent searches logic is complex and we shouldn't duplicate that in multi search template api, so we should template each individual template search request and then delegate to multi search api.
2017-05-10Rewrite multi search template api to delegate to multi search api instead of ↵Martijn van Groningen
to search template api. The max concurrent searches logic is complex and we shouldn't duplicate that in multi search template api, so we should template each individual template search request and then delegate to multi search api.
2017-05-10This adds max_concurrent_searches to multi-search-template endpoint.Isabel Drost-Fromm
Closes #20912
2017-05-10Scripting: Remove "service" from ScriptEngine interface name (#24574)Ryan Ernst
This commit renames ScriptEngineService to ScriptEngine. It is often confusing because we have the ScriptService, and then ScriptEngineService implementations, but the latter are not services as we see in other places in elasticsearch.
2017-04-24Templates: Add compileTemplate method to ScriptService for template ↵Ryan Ernst
consumers (#24280) This commit adds a compileTemplate method to the ScriptService. Eventually this will be used to easily cutover all consumers to a new TemplateService. relates #16314
2017-04-21Scripts: Remove unnecessary executable shortcut (#24264)Ryan Ernst
ScriptService has two executable methods, one which takes a CompiledScript, which is similar to search, and one that takes a raw Script and both compiles and returns an ExecutableScript for it. The latter is not needed, and the call sites which used one or the other were mixed. This commit removes the extra executable method in favor of callers first calling compile, then executable.
2017-03-01Mustache: don't extend AbstractComponent (#23419)Nik Everett
Don't extend `AbstractComponent` in `MustacheScriptEngine` because it doesn't buy anything.
2017-02-22Remove content type auto-detection from search templatesjavanna
Now that search templates always get converted to json, we don't need to try and auto-detect their content-type, which anyways didn't work as expected before given that only json was really working.
2017-02-22Convert script/template objects to json formatjavanna
Elasticsearch accepts multiple content-type formats, hence scripts can be stored/provided in json, yaml, cbor or smile. Yet the format that should be used internally is json. This is a problem mainly around search templates, as they only support json out of the four content-types, so instead of maintaining the content-type of the request we should rather convert the scripts/templates to json. Binary formats were not previously supported. If you stored a template in yaml format, you'd get back an error "No encoder found for MIME type [application/yaml]" when trying to execute it. With this commit the request content-type is independent from the template, which always gets converted to json internally. That is transparent to users and doesn't affect the content type of the response obtained when executing the template.
2017-02-22Replace CustomMustacheFactory constant with same constant from Script ↵javanna
(CONTENT_TYPE_OPTION)
2017-02-10Use `typed_keys` parameter to prefix suggester names by type in search ↵Tanguy Leroux
responses (#23080) This pull request reuses the typed_keys parameter added in #22965, but this time it applies it to suggesters. When set to true, the suggester names in the search response will be prefixed with a prefix that reflects their type.
2017-02-09Add parameter to prefix aggs name with type in search responses (#22965)Tanguy Leroux
This pull request adds a new parameter to the REST Search API named `typed_keys`. When set to true, the aggregation names in the search response will be prefixed with a prefix that reflects the internal type of the aggregation. Here is a simple example: ``` GET /_search?typed_keys { "aggs": { "tweets_per_user": { "terms": { "field": "user" } } }, "size": 0 } ``` And the response: ``` { "aggs": { "sterms:tweets_per_user": { ... } } } ``` This parameter is intended to make life easier for REST clients that could parse back the prefix and could detect the type of the aggregation to parse. It could also be implemented for suggesters.
2017-02-07Add support for newline delimited JSON Content-Type (#22947)Jay Modi
This commit adds support for the newline delimited JSON Content-Type, which is how the bulk, multi-search, and multi-search template APIs expect data to be formatted. The `elasticsearch-js` client has also been using this content type for these types of requests. Closes #22943
2017-02-03Upgrade checkstyle to version 7.5Jason Tedor
This commit upgrades the checkstyle configuration from version 5.9 to version 7.5, the latest version as of today. The main enhancement obtained via this upgrade is better detection of redundant modifiers. Relates #22960
2017-02-02Optionally require a valid content type for all rest requests with content ↵Jay Modi
(#22691) This change adds a strict mode for xcontent parsing on the rest layer. The strict mode will be off by default for 5.x and in a separate commit will be enabled by default for 6.0. The strict mode, which can be enabled by setting `http.content_type.required: true` in 5.x, will require that all incoming rest requests have a valid and supported content type header before the request is dispatched. In the non-strict mode, the Content-Type header will be inspected and if it is not present or not valid, we will continue with auto detection of content like we have done previously. The content type header is parsed to the matching XContentType value with the only exception being for plain text requests. This value is then passed on with the content bytes so that we can reduce the number of places where we need to auto-detect the content type. As part of this, many transport requests and builders were updated to provide methods that accepted the XContentType along with the bytes and the methods that would rely on auto-detection have been deprecated. In the non-strict mode, deprecation warnings are issued whenever a request with body doesn't provide the Content-Type header. See #19388
2017-01-31Change Namespace for Stored Script to Only Use Id (#22206)Jack Conradson
Currently, stored scripts use a namespace of (lang, id) to be put, get, deleted, and executed. This is not necessary since the lang is stored with the stored script. A user should only have to specify an id to use a stored script. This change makes that possible while keeping backwards compatibility with the previous namespace of (lang, id). Anywhere the previous namespace is used will log deprecation warnings. The new behavior is the following: When a user specifies a stored script, that script will be stored under both the new namespace and old namespace. Take for example script 'A' with lang 'L0' and data 'D0'. If we add script 'A' to the empty set, the scripts map will be ["A" -- D0, "A#L0" -- D0]. If a script 'A' with lang 'L1' and data 'D1' is then added, the scripts map will be ["A" -- D1, "A#L1" -- D1, "A#L0" -- D0]. When a user deletes a stored script, that script will be deleted from both the new namespace (if it exists) and the old namespace. Take for example a scripts map with {"A" -- D1, "A#L1" -- D1, "A#L0" -- D0}. If a script is removed specified by an id 'A' and lang null then the scripts map will be {"A#L0" -- D0}. To remove the final script, the deprecated namespace must be used, so an id 'A' and lang 'L0' would need to be specified. When a user gets/executes a stored script, if the new namespace is used then the script will be retrieved/executed using only 'id', and if the old namespace is used then the script will be retrieved/executed using 'id' and 'lang'
2017-01-21Add single static instance of SpecialPermission (#22726)Tim Brooks
This commit adds a SpecialPermission constant and uses that constant opposed to introducing new instances everywhere. Additionally, this commit introduces a single static method to check that the current code has permission. This avoids all the duplicated access blocks that exist currently.
2017-01-20Deguice rest handlers (#22575)Nik Everett
There are presently 7 ctor args used in any rest handlers: * `Settings`: Every handler uses it to initialize a logger and some other strange things. * `RestController`: Every handler registers itself with it. * `ClusterSettings`: Used by `RestClusterGetSettingsAction` to render the default values for cluster settings. * `IndexScopedSettings`: Used by `RestGetSettingsAction` to get the default values for index settings. * `SettingsFilter`: Used by a few handlers to filter returned settings so we don't expose stuff like passwords. * `IndexNameExpressionResolver`: Used by `_cat/indices` to filter the list of indices. * `Supplier<DiscoveryNodes>`: Used to fill enrich the response by handlers that list tasks. We probably want to reduce these arguments over time but switching construction away from guice gives us tighter control over the list of available arguments. These parameters are passed to plugins using `ActionPlugin#initRestHandlers` which is expected to build and return that handlers immediately. This felt simpler than returning an reference to the ctors given all the different possible args. Breaks java plugins by moving rest handlers off of guice.
2017-01-17Simplify ElasticsearchException rendering as a XContent (#22611)Tanguy Leroux
This commit tries to simplify the way ElasticsearchException are rendered to xcontent. It adds some documentation and renames and merges some methods. Current behavior is preserved, the goal is to be more readable and centralize everything in the ElasticsearchException class.
2017-01-12Remove ParseFieldMatcher usages from IndexSettingsjavanna
2017-01-12Remove ParseFieldMatcher usages from QueryParseContextjavanna
2017-01-11Remove SearchRequestParsers (#22538)Nik Everett
It is empty now that we've moved all the parsing into `namedObject`.
2017-01-09Replace Suggesters with namedObject (#22491)Nik Everett
Removes another parser registery type thing in favor of `XContentParser#namedObject`.
2017-01-09Replace AggregatorParsers with namedObject (#22397)Nik Everett
Removes `AggregatorParsers`, replacing all of its functionality with `XContentParser#namedObject`. This is the third bit of payoff from #22003, one less thing to pass around the entire application.
2017-01-09Replace SearchExtRegistry with namedObject (#22492)Nik Everett
This is one of the last things in `SearchRequestParsers`.
2017-01-06Make StatusToXContent extend ToXContentObject and rename it to ↵javanna
StatusToXContentObject This also allows to make RestToXContentListener require ToXContentObject rather than ToXContent
2017-01-06Make SearchResponse a ToXContentObjectjavanna
2017-01-06Migrate some more responses to ToXContentObjectjavanna
2017-01-05remove ParseFieldMatcher usages from RestSearchTemplateActionjavanna
2017-01-05remove ParseFieldMatcher usages from Script parsing codejavanna
2016-12-21Replace IndicesQueriesRegistry (#22289)Nik Everett
* Switch query parsing to namedObject * Remove IndicesQueriesRegistry