Commit Graph

6203 Commits

Author SHA1 Message Date
Armin Braun 096b8ccc26
Fix TextFieldMapper Retaining a Reference to its Builder (#77251)
Fixes the text field mapper and the analyzers class that also retained parameter references that go really heavy.
Makes `TextFieldMapper` take hundreds of bytes compared to multiple kb per instance.

closes #73845
2021-09-03 18:44:11 +02:00
Jake Landis 26dfe02a0b
Update task names for rest compatiblity (#75267)
This commit updates two task names:
```
yamlRestCompatTest -> yamlRestTestV7CompatTest
transformV7RestTests -> yamlRestTestV7CompatTransform 
```

`7` is the N-1 version and calculated, such that when `8` is 
N-1 version the task names will be  `yamlRestTestV8CompatTest` and 
`yamlRestTestV8CompatTransform`

The motivation for `yamlRestCompatTest -> yamlRestTestV7CompatTest`  is that 
many projects have configured `yamlRestCompatTest` 
but that configuration is specific to the N-1 version. For example, 
if we blacklist tests when running compatibility with v7, we don't also
want to blacklist those tests when running compatibility with v8.

By introducing a version-specific identifier in the name, the task will not
even exist when bumping the version creating the need to (correctly) remove
the version-specific condition.

The motivation for `transformV7RestTests -> yamlRestTestV7CompatTransform` 
is to provide more consistent naming. 

The idea behind the naming is the main task people
are likely familiar with is :

`yamlRestTest` so we will use that as a base.
`yamlRestTestV7CompatTest` to run the version-specific compat tests
`yamlRestTestV7CompatTransform` to run the version-specific transformations for the compat tests

CI should be un-effected since since we introduced a lifecycle task 
name `checkRestCompat` which is what CI should be configured to use.
2021-09-03 11:26:11 -05:00
Seth Michael Larson eaf4ac26cc
Convert 'routing' values in REST API tests to strings
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-09-03 07:33:26 -05:00
Armin Braun 38faeefd85
Fix MatchOnlyTextFieldMapper Retaining a Reference to its Builder (#77201)
Just like #77131 but for the `MatchOnlyTextFieldMapper`. Also, cleaned up a few
other minor things in it to make the constructor code for this class easier to follow.
2021-09-03 10:43:40 +02:00
David Turner bfcc93a042
Anonymize AbstractRefCounted (#77208)
Today `AbstractRefCounted` has a `name` field which is only used to
construct the exception message when calling `incRef()` after it's been
closed. This isn't really necessary, the stack trace will identify the
reference in question and give loads more useful detail besides. It's
also slightly irksome to have to name every single implementation.

This commit drops the name and the constructor parameter, and also
introduces a handy factory method for use when there's no extra state
needed and you just want to run a method or lambda when all references
are released.
2021-09-03 07:59:44 +01:00
Ignacio Vera 63310fd86c
Remove unused geo module (#77016)
Module was used to register geo_shape mapping into the oss distribution.
2021-09-03 07:12:01 +02:00
Jake Landis edcdd30b62
Compatible REST API - minor build clean up (#77145)
This commit allows the compatible REST API tests to execute on Windows.
They were previously excluded from Windows due to a command line limit
when defining a very large exclusion list. That exclusion list is much
smaller now and they will now execute properly on Windows.

Also, an empty exclusion list has been removed from the build config.
2021-09-01 15:51:14 -05:00
Nik Everett 429beba517
Centralize doc values checking (#77089)
This adds two utility methods for to validate the parameters to the
`docValueFormat` method and replaces a pile of copy and pasted code with
calls to them. They just emit a standard error message if the any
unsupported parameters are provided.
2021-09-01 09:06:24 -04:00
Dan Hermann 6a141236df
Re-enable REST compatibility test after backport of #76752 2021-09-01 06:18:38 -05:00
Christos Soulios 707dd497e4
Add multiple validators to Parameters (#77073)
This PR implements support for multiple validators to a FieldMapper.Parameter.

The Parameter#setValidator method was replaced by Parameter#addValidator that can be called multipled times
to add validation to a parameter.

All validators of a parameter will be executed in the same order as they have been added and if any of them fails all validation will failed.
2021-08-31 21:28:14 +03:00
Jack Conradson 9e9a6d5601
Adds a lookup method to Painless for finding methods of all sub classes (#77044)
This change adds a method to the PainlessLookup used to find methods of all allow listed sub classes. 
A method is specified for a specific super class, and then a list is built with all matching methods from 
the all the allow listed sub classes. If no matches are found, null is returned which is consistent with 
the behavior of the other look up methods. It is up to the caller to check.
2021-08-31 08:12:04 -07:00
Dan Hermann 90d2899323
ECS support for Grok processor (#76885) 2021-08-31 06:40:52 -05:00
Rene Groeschke 35ec6f348c
Introduce simple public yaml-rest-test plugin (#76554)
This introduces a basic public yaml rest test plugin that is supposed to be used by external 
elasticsearch plugin authors. This is driven by #76215

- Rename yaml-rest-test to intern-yaml-rest-test
- Use public yaml plugin in example plugins

Co-authored-by: Mark Vieira <portugee@gmail.com>
2021-08-31 08:45:52 +02:00
Mark Tozzi d715449766
Apply spotless to aggregations (#76682)
* spotless apply for core analytics code

* spotless apply for x-pack:plugin:analytics

* spotless apply for matrix stats

* don't format huge lists of HLL constants

* Spotless for Rollups

* Don't exclude HLLPP, we added narrower inline exclusions
2021-08-30 13:42:20 -04:00
Jack Conradson 718b1635e2
Add a direct sub classes data structure to the Painless lookup (#76955)
This change has two main components.

The first is to have method/field resolution for compile-time and run-time use the same code path for 
now. This removes copying of member methods between super and sub classes and instead does a 
resolution through the class hierarchy. This allows us to correctly implement the next change.

The second is a data structure that allows for the lookup of direct sub classes for all allow listed 
classes/interfaces within Painless.
2021-08-26 12:09:43 -07:00
Stuart Tettemer 3c737341fe
Script: Fields API converter tests (#76900) 2021-08-26 09:18:42 -05:00
Przemko Robakowski 99c85f8e70
Fix disabling GeoIP downloader through elasticsearch.yml (#76924)
This change allows user to disable GeoIP downloader using elasticsearch.yml and it deletes .geoip_databases index if downloader is disabled.

Closes #76586
2021-08-26 08:47:37 +02:00
Dan Hermann d648b768d8
Sync grok processor patterns with Logstash (#76752) 2021-08-24 07:34:27 -05:00
markharwood 81e0bc2031
NullPointer fix for field capabilities API (#76742)
Composite runtime fields do not have a mapped type - add null check, test and Nullable annotation to SearchExecutionContext.getObjectMapper(name)

Closes #76716
2021-08-23 09:06:59 +01:00
Rory Hunter bf4e01e98e
Fix spotless gradle config (#76701)
An attempt to apply the spotless plugin everywhere and then disable
where it wasn't appropriate didn't work, and instead everything was
formatted. Revert how we apply the pluing, and use a different approach
to applying extra configuration in build files.
2021-08-19 14:38:21 +01:00
Przemyslaw Gomulka 127015e54c
[Rest Api Compatibility] Clean up blocklist (#76179)
v7compatibilityNotSupportedTests was introduced to make it easier to
track tests that have been identified as not needing compatible changes
and those that still need to be checked.
We have checked all tests now and the separate list is no longer needed.

relates #51816
relates #73912
2021-08-19 10:09:46 +02:00
Jack Conradson e3985801a1
Add ability to augment classes with fields from other classes in Painless (#76628)
This change adds a a new "augmented" annotation to the Painless allowlist parser. The first use of the 
annotation supports adding static final fields to a specified allowlist class from another class. This 
supports the fields api as we can add additional fields types from other classes and augment the Field 
class with the new types.
2021-08-18 11:19:07 -07:00
Mark Vieira 13795c4e5e
Use Adoptium builds for bundled JDK (#76631) 2021-08-18 09:52:22 -07:00
Rory Hunter d01efa4fd6
Changes to keep Checkstyle happy after reformatting (#76464)
* Reformatting to keep Checkstyle after formatting

* Configure spotless everywhere, and disable the tasks if necessary

* Add XContentBuilder helpers, fix test

* Tweaks

* Add a TODO

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-08-18 07:15:55 -04:00
Jack Conradson dd8f0f3ff0
Move AnnotationTestObject to test package (#76619)
An extraneous test class was part of the spi core package. This change moves it to the test package. 
Also fixes a typo.
2021-08-17 11:11:17 -07:00
Stuart Tettemer aea8bfffc8
Script: ulong via fields API (#76519)
* Script: ulong via fields API

Exposes unsigned long via the fields API.

Unsigned longs default to java signed longs.  That means the upper range
appears negative.  Consumers should use `Long.compareUnsigned(long, long)`
`Long.divideUnsigned(long, long)` and `Long.remainderUnsigned(long, long)`
to correctly work with values known to be unsigned long.

Alternatively, users may treat the unsigned long type as `BigInteger` using
the field API, `field('ul').as(Field.BigInteger).getValue(BigInteger.ZERO)`.
```
field('ul').as(Field.BigInteger).getValue(BigInteger.valueOf(1000))
field('ul').getValue(1000L)
```

This change also implements the beginning of the converters for the fields
API.  The following conversions have been added:
```
ulong <-> BigInteger
long <-> BigInteger
double -> BigInteger
String (parsed as long or double) -> BigInteger
double -> long
String (parsed as long or double) -> long
Date (epoch milliseconds) -> long
Nano Date (epoch nanoseconds) -> long
boolean (1L for true, 0L for false) -> long
```
2021-08-17 10:06:28 -05:00
Dan Hermann dd7eedea78
Map iteration support for ForEach processor (#64062) 2021-08-17 07:21:46 -05:00
Jack Conradson 82919dab52
fix the error message for instance methods that don't exist (#76512)
This fixes the error message in Painless for when an instance-style method isn't found. It now prints the 
number of arguments instead of the memory location of the nodes data structure.
2021-08-16 08:08:47 -07:00
Nik Everett f56d7fcc55
Fix eclipse compilation after plugin spi (#76437)
Painless extensions now compile against it's `spi` subproject. Gradle
and IntelliJ rig the dependencies correctly but Eclipse doesn't seem to
manage it. This temporarily declares the `spi` as a `compileOnly`
dependency when in Eclipse land so Eclipse can see the classes.
2021-08-13 10:50:21 -04:00
Nik Everett e305a6bed7
Name `BulkItemResponse` ctors (#76439)
* Name `BulkItemResponse` ctors

`BulkItemResponse` can contain either a success or failure. This
replaces the two constructors used to build either case with named
static methods. So instead of
```
return new BulkItemResponse(0, OpType.CREATE, createResponse);
return new BulkItemResponse(0, OpType.CREATE, failure);
```
you now use
```
return BulkItemResponse.success(0, OpType.CREATE, createResponse);
return BulkItemResponse.failure(0, OpType.CREATE, failure);
```

This makes it marginally easier to read code building these things - you
don't have to know the type of the parameter to know if its a failure
or success.

* Consistent

* Mock response
2021-08-12 14:41:26 -04:00
Jack Conradson 63425d50b2
Clean up whitelist loading for core contexts in painless plugin (#76392)
This change creates a standard for loading additional allow listed elements for the core contexts 
within the ScriptPlugin. For each core context we look for org.elasticsearch.script.<context-name>.txt 
and if it exists we load it automatically for that context.
2021-08-12 08:22:10 -07:00
Ryan Ernst dfcb3416b8
Fix generation of javadocs (#76382)
The javadoc generation for painless api classes was broken by a recent
commit. This commit fixes it by correct the classpath used to run the
javadoc task. Additionally, the task is added to `check` to ensure it
runs with CI.

closes #76373
2021-08-11 18:33:19 -04:00
Armin Braun b01cd8ff87
Radomize BlobContainer Path in Retries Tests (#76303)
Follow up to #76273 adding some randomization across all retries tests.
2021-08-11 22:31:04 +02:00
Jack Conradson a48c7369a2
Add Fields API to aggregation scripts and field scripts (#76325)
This change updates the aggregation script, map script for aggregations, and field scripts to extend 
DocBasedScript to give them access to the new fields api.
2021-08-11 08:32:36 -07:00
Ryan Ernst 35980c8da6
Add support in plugins for a separate spi classloader (#76288)
* Add support in plugins for a separate spi classloader

SPI is how plugins provide extension points for other plugins to
customize their behavior. Plugins may have a separate SPI jar, so as not
to expose the internals of the plugin implementation. In essense, this
system was built as a stopgap for Java modules, where implementation can
be protected in the same jar. However, currently the plugins service
loads both spi and plugin implementations into the same classloader.
This means that although another plugin may only compile against spi,
they could still get jar hell from a duplicate dependency.

This commit adds support for plugins to contain an "spi" subdirectory
which is loaded into a separate classloader. This spi classloader is a
parent to the plugin implementation, as well as any other plugins which
have extended it. Additionally as a demonstration of how this works in
practice, lang-painless is setup as the first plugin to provide an spi
jar, and sql's dependence on painless is changed to only spi, so that
it now has an independent version of antlr.

closes #74448

* Change eql to use painless spi

* checkstyle

* add licens files to eql for antlr

* Address review
2021-08-11 09:59:29 -04:00
Dan Hermann c81cf2f7fe
Configurable media_type for mustache template encoding on append processor (#76210) 2021-08-10 15:13:36 -05:00
Luca Cavanna 32d2f60f8a
Emit multiple fields from a runtime field script (#75108)
We have recently introduced support for grok and dissect to the runtime fields 
Painless context that allows to split a field into multiple fields. However, each runtime 
field can only emit values for a single field. This commit introduces support for emitting 
multiple fields from the same script.

The API call to define a runtime field that emits multiple fields is the following:

```
PUT localhost:9200/logs/_mappings
{
    "runtime" : {
      "log" : {
        "type" : "composite",
        "script" : "emit(grok(\"%{COMMONAPACHELOG}\").extract(doc[\"message.keyword\"].value))",
        "fields" : {
            "clientip" : {
                "type" : "ip"
            },
            "response" : {
                "type" : "long"
            }
        }
      }
    }
}
```

The script context for this new field type accepts two emit signatures:

* `emit(String, Object)`
* `emit(Map)`

Sub-fields need to be declared under fields in order to be discoverable through 
the field_caps API and accessible through the search API. 

The way that it emits multiple fields is by returning multiple MappedFieldTypes 
from RuntimeField#asMappedFieldTypes. The sub-fields are instances of the 
runtime fields that are already supported, with a little tweak to adapt the script 
defined by their parent to an artificial script factory for each of the sub-fields 
that makes its corresponding sub-field accessible. This approach allows to reuse 
all of the existing runtime fields code for the sub-fields.

The runtime section has been flat so far as it has not supported objects until now. 
That stays the same, meaning that runtime fields can have dots in their names. 
Because there are though two ways to create the same field with the introduction 
of the ability to emit multiple fields, we have to make sure that a runtime field with 
a certain name cannot be defined twice, which is why the following mappings are 
rejected with the error `Found two runtime fields with same name [log.response]`:

```
PUT localhost:9200/logs/_mappings
{
    "runtime" : {
        "log.response" : {
            "type" : "keyword"
        },
        "log" : {
            "type" : "composite",
            "script" : "emit(\"response\", grok(\"%{COMMONAPACHELOG}\").extract(doc[\"message.keyword\"].value)?.response)",
            "fields" : {
                "response" : {
                    "type" : "long"
                }
            }
        }
    }
}
```

Closes #68203
2021-08-10 13:07:53 +01:00
Armin Braun 46ebb2298c
Fix S3 Streaming Writes Ignoring Relative Paths for Large Writes (#76273)
It's in the title, we were not accounting for relative paths at all
here and only saved by the fact that we mostly short-circuit to
non-streaming writes.
Extended testing to catch this case for S3 and would do a follow-up
to extend it for the other implementations as well.
2021-08-10 13:36:25 +02:00
Armin Braun 873fbf7b65
Fix Leaking Http Channel Objects when Http Client Stats are Disabled (#76257)
We have to remove the channel from the internal collection of channels when stats are disabled.

Closes #76183
2021-08-10 12:39:12 +02:00
Ryan Ernst 43a534e95a
Move painless base whitelist into painless jar (#76262)
The base whitelist is shared by all script contexts. However, the text
files exist within painless itself, not the limited spi jar which is
meant for extension. This commit moves the base definition into painless
and reworks context loading in painless to add the base whitelist so
that all contexts get it, regardless of whether they have added an
explicit whitelist.
2021-08-09 18:10:37 -07:00
Jack Conradson 6f1fbc1133
Add fields api to runtime fields contexts (#76265)
This changes extends AbstractFieldScript with DocBasedScript to make the fields API accessible to runtime fields contexts.
2021-08-09 16:12:03 -07:00
Rene Groeschke b323726ebd
Resolve system properties in build scripts via provider factory (#76199)
This allows tracking system properties used in the build configuration and brings us
one step closer to be gradle configuration cache compliant.
2021-08-09 09:39:30 +02:00
Przemyslaw Gomulka 782e2c67f8
[Rest Api Compatibility] CommonTermsQuery and cutoff_frequency param (#75896)
Previously removed in #42654. The query and the parameter won't work under rest api compatibility and an exception with a message is returned advising that just use of match/multi_match is enough

relates #51816
2021-08-05 15:14:28 +02:00
Armin Braun d510fa4841
Upgrade to Netty 4.1.66 (#76135)
Upgrade to 4.1.66 which might bring some helpful
improvements to how TLS exceptions are propagated.
2021-08-05 09:24:52 +02:00
Yang Wang bad4e88278
[Test] Allow trace.id in default thread context (#76089)
A new trace.id header is added by #74210. It is handled almost the same
way as x-opaque-id. Specifically, it gets passed into default thread
context. This means the existing assertion should expect it in addition
to x-opaque-id.
2021-08-05 10:45:05 +10:00
Stuart Tettemer bb9c91fc57
Script: Fields API for Filter context (#76119) 2021-08-04 14:29:43 -05:00
Stuart Tettemer 858cc3297f
Script: Remove FieldAccess (#76109)
Remove FieldAccess inner class from fields api classes
based on changes in #76045
2021-08-04 11:41:43 -05:00
Stuart Tettemer 6c02a6c657
Script: Fields API for Sort and Score scripts (#75863)
Adds minimal fields API support to sort and score scripts.

Example: `field('myfield').getValue(123)` where `123` is the default if the field has no values.

Refs: #61388
2021-08-04 10:11:12 -05:00
Henning Andersen b19f601ae0
Remote reindex stored fields since 5.0.0 (#74914)
Test would assume stored fields were available since 5.0.0.alpha4,
while production code only enables them after 5.0.0 (final, aka 99).

Closes #74131
2021-08-04 16:06:17 +02:00
Jack Conradson f898c30dc9
Add ability to allow list instance methods on the script class (#76045)
This change adds support to allow list instance methods on the script class in Painless and super 
classes of the script class. It works the same way as allow listing works now for other classes.
2021-08-03 13:15:40 -07:00