Commit graph

50 commits

Author SHA1 Message Date
Rene Groeschke
49c0f5cf71
Update Gradle wrapper to 8.12 (#118683) (#119356)
This updates the gradle wrapper to 8.12

We addressed deprecation warnings due to the update that includes:

- Fix change in TestOutputEvent api
- Fix deprecation in groovy syntax
- Use latest ospackage plugin containing our fix
- Remove project usages at execution time
- Fix deprecated project references in repository-old-versions

(cherry picked from commit ba61f8c7f7)

# Conflicts:
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/distribution/DockerUbiElasticsearchDistributionType.java
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/Fixture.java
#	plugins/repository-hdfs/hadoop-client-api/build.gradle
#	qa/entitlements/build.gradle
#	server/src/main/java/org/elasticsearch/indices/IndicesFeatures.java
#	x-pack/plugin/migrate/build.gradle
#	x-pack/plugin/security/qa/security-basic/build.gradle
2024-12-31 08:37:12 +01:00
Kostas Krikellas
2439869034
[8.x] [TEST] Replace _source.mode with index.mapping.source.mode in integration tests - take 2 (#116072) (#116161)
* [TEST] Replace _source.mode with index.mapping.source.mode in integration tests - take 2 (#116072)

* Reapply "[TEST] Replace _source.mode with index.mapping.source.mode in integra…" (#116069)

This reverts commit e8bf344a28.

* [TEST] Replace _source.mode with index.mapping.source.mode in integration tests

* add reason

* add reason

* spotless

* revert unneeded

(cherry picked from commit 4573ab8ec1)

# Conflicts:
#	server/src/main/java/org/elasticsearch/index/mapper/MapperFeatures.java

* Update MapperFeatures.java
2024-11-04 19:45:47 +11:00
Ryan Ernst
dedf9fd6d7
Use directory name as project name for libs (#115720) (#115984)
* Use directory name as project name for libs (#115720)

The libs projects are configured to all begin with `elasticsearch-`.
While this is desireable for the artifacts to contain this consistent
prefix, it means the project names don't match up with their
directories. Additionally, it creates complexities for subproject naming
that must be manually adjusted.

This commit adjusts the project names for those under libs to be their
directory names. The resulting artifacts for these libs are kept the
same, all beginning with `elasticsearch-`.

* fixes
2024-10-31 07:52:10 +11:00
Mayya Sharipova
7719f17457
Deprecate legacy params from range query (#113286) (#113610)
Deprecate to, from, include_lower, include_upper range query params.
These params have been removed from our documentation in v. 0.90.4 (d6ecdecc19),
but did not got through deprecation cycle.

These params to be removed in v9.0.

Related to #81276

Closes #48538
2024-09-27 01:10:46 +10:00
Mark Vieira
0279c0a909
Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
Simon Cooper
3a36785908
Update last few references in yaml tests from ROOT locale to ENGLISH (#112791) (#112802) 2024-09-12 12:36:47 +01:00
Simon Cooper
a36d90cf34
Use CLDR locale provider on JDK 23+ (#110222)
JDK 23 removes the COMPAT locale provider, leaving CLDR as the only option. This commit configures Elasticsearch
to use the CLDR provider when on JDK 23, but still use the existing COMPAT provider when on JDK 22 and below.

This causes some differences in locale behaviour; this also adapts various tests to still work whether run on COMPAT or CLDR.
2024-09-04 13:42:40 +01:00
David Turner
0367e3b1de
Make constant threadPool.relativeTimeInMillisSupplier() (#104311)
We use `ThreadPool#relativeTimeInMillis` as part of a timeout mechanism
in many places, often using a method reference so we can pass in a
`LongSupplier` for ease of testing. Each time we create a new method
reference we're opening ourselves up to potential cache misses on the
way through to the two volatile reads needed to actually return the
value in production. We're also only caching the nanos value so we must
do some arithmethic to convert it to millis each time.

This commit introduces a constant `LongSupplier` for use in all these
places, saving the allocation and the indirection through different
objects, and caching the millis value alongside the nanos to avoid the
arithmetic on each call.

Relates #104273
2024-07-31 02:26:18 +10:00
Moritz Mack
1f5e04b721
Migrate YAML REST tests to synthetic cluster feature check (#107068)
To simplify the migration away from version based skip checks in YAML specs, 
this PR adds a synthetic version feature `gte_vX.Y.Z` for any version at or before 8.14.0.

New test specs for 8.14 or later are expected to use respective new cluster features,
or a test-only feature supplied via ESRestTestCase#createAdditionalFeatureSpecifications
if sufficient.
2024-04-11 18:22:38 +02:00
Salvatore Campagna
999dcb8d08
Unable to retrieve multiple stored field values (#106575)
The issue happens when we try to use multiple stored fields through
the FetchFieldsPhase, which we do when using `_fields` since
we have a single shared instance of SingleFieldsVisitor per field
and document and use a shared `currentValues` array.
2024-03-21 13:35:17 +01:00
Simon Cooper
22381fd6a7
Refactor overrides of old Plugin.createComponents method to new services method (#101381) 2023-10-26 16:58:14 +01:00
Mark Vieira
2a6c16079c
Migrate painless and runtime fields common tests to new test clusters (#101021) 2023-10-18 07:39:39 -07:00
Kostas Krikellas
137bb45662
Support runtime fields in synthetic source (#99796)
* Support runtime fields in synthetic source

* Update docs/changelog/99796.yaml

* Introduce SyntheticSourceProvider

* Address comments

* More fixes

* Fix checkstyle violation

* More unittest updates

* Use SourceProvider in MapperServiceTestCase

* Remove runtime field from unittest

* Update synthetic source doc
2023-09-26 14:29:56 +03:00
Przemyslaw Gomulka
eca41871aa
Use TelemetryProvider in Plugin::createComponents (#99737)
in order to avoid adding yet anther parameter to createComponents
a Tracer interface is replaced with TelemetryProvider.
this allows to get both Tracer and Metric (in the future) interfaces
2023-09-22 14:48:11 +02:00
Przemyslaw Gomulka
b6747b48ba
Rename tracing to telemetry package (#99710)
This commit renames the tracing to telemetry.tracing in both xpack/APM and elasticserach's org.elasticsearch.tracing.Tracer (the api)
the xpack/APM is renamed as follows:
org.elasticsearch.telemetry.apm - the only exported package
org.elasticsearch.telemetry.apm.settings - APMSettings
org.elasticsearch.telemetry.apm.tracing - APMTracer

org.elasticsearch.tracing.Tracer is moved to org.elasticsearch.telemetry.tracing.Tracer (responsible for majority of the changes in this PR)
2023-09-20 16:58:02 +02:00
David Turner
a20ee3f8f2
Migrate simple usages of ThreadPool#schedule (#99051)
In #99027 we deprecated the string-based version of
`ThreadPool#schedule`. This commit migrates all the simple usages of
this API to the new version.
2023-08-31 07:37:31 +01:00
Ievgen Degtiarenko
d9b6c5ae29
Wire IndicesService to plugins (#97081)
This change exposes IndicesService to the plugins via Plugin#createComponents
2023-06-27 18:02:23 +02:00
Rory Hunter
fe1083f6c5
Upgrade spotless plugin to 6.17.0 (#94994)
Fixes #82794. Upgrade the spotless plugin, which addresses the issue
around formatting `instanceof` expressions. Formatting of statements
including lambdas seems to have improved too.
2023-04-04 10:03:32 +01:00
Ryan Ernst
e5a61067e7
Modularize runtime-fields-common (#93719)
This change modulares the runtime-fields-common component by adding a
module-info.java.

relates #78744
2023-03-03 13:30:17 -08:00
Pablo Alcantar Morales
66fcf65a58
Split Grok's responsibilities (#93987)
* extract ECS compatibility modes
* moves builtin patterns loading logic to its own class
* split loading logic into their own method and extracting commonalities
* 2 new alias methods to clearly state what pattern are you trying to get
2023-03-01 10:10:54 +01:00
Ievgen Degtiarenko
ad229dd70e
Update createComponents to supply AllocationService instead of AllocationDeciders (#92785) 2023-01-10 14:18:33 +01:00
Christoph Büscher
8067f01d48
Runtime fields to optionally ignore script errors (#92380)
Currently Elasticsearch always returns a shard failure once a runtime error arises from using a runtime field, the exception being script-less runtime fields. This also means that execution of the query for that shard stops, which is okay for development and exploration. In a production scenario, however, it is often desirable to ignore runtime errors and continue with the query execution.

This change adds a new a new on_script_error parameter to runtime field definitions similar to the already existing
parameter for index-time scripted fields. When `on_script_error` is set to `continue`, errors from script execution are effectively ignored. This means affected documents don't show up in query results, but also don't prevent other matches from the same shard. Runtime fields accessed through the fields API don't return values on errors, aggregations will ignore documents that throw errors.

Note that this change affects scripted runtime fields only, while leaving default behaviour untouched. Also, ignored errors are not reported back to users for now.

Relates to #72143
2022-12-23 09:29:12 +01:00
Mark Vieira
c2eda511de
Add JUnit rule based integration test cluster orchestration framework (#92379)
This commit adds a new test framework for configuring and orchestrating
test clusters for both Java and YAML REST testing. This will eventually
replace the existing "test-clusters" Gradle plugin and the build-time
cluster orchestration.
2022-12-21 15:33:46 -08:00
Nikola Grcevski
fc819609a1
Add allocation deciders in createComponents (#89836)
With this change we are adding the allocation deciders
in create components we can simplify the use in the
Autoscaling plugin and implement reserved state handler
in the future.
2022-09-07 09:28:07 -04:00
Alan Woodward
189f279b4f
Don't modify source map when parsing composite runtime field (#89114)
When calling RuntimeField.parseRuntimeFields() for fields defined in the
search request, we need to wrap the Map containing field definitions in another
Map that supports value removal, so that we don't inadvertently remove the
definitions from the root request. CompositeRuntimeField was not doing this
extra wrapping, which meant that requests that went to multiple shards and
that therefore parsed the definitions multiple times would throw an error
complaining that the fields parameter was missing, because the root request
had been modified.
2022-08-17 10:00:16 +01:00
Nik Everett
3bcee8eaa0
Format runtime geo_points (#85449)
This formats the result of the `fields` section of the `_search` API for
runtime `geo_point` fields using the `format` parameter like we do for
non-runtime `geo_point` fields. This changes the default format for
those fields from `lat, lon` to `geojson` with the option to get `wkt`
or any other format we support.

The fix does so by preserving the `double, double` nature of the
`geo_point` rather than encoding it immediately in the script. Callers can
use the results. The field fetchers use the `double, double` natively,
preserving as much precision as possible. The queries quantize the points
exactly like lucene indexing does. And like the script did before this Pr.

Closes #85245
2022-07-27 13:11:07 -04:00
Rory Hunter
5c5981d27d
Introduce tracing interfaces (#87921)
Part of #84369. Split out from #87696. Introduce tracing interfaces in
advance of adding APM support to Elasticsearch. The only implementation
at this point is a no-op class.
2022-07-26 05:31:41 +09:30
Rene Groeschke
718a241449
Apply precommit checks for non productive projects (#85533)
Ensure projects with only yaml, java or cluster tests also apply precommit checks.
We only apply testingconventions now for projects with existing src test folder
as the TestingConventionsTask is incompatible with projects with no test sourceSet.
This is a prerequisite to port more projects away from using StandaloneRestTestPlugin
and RestTestPlugin in favor of yaml, java or cluster tests with dedicated sourceSets.

Also we fix deprecation warnings for forbiddenPattern and filePermissions tasks about
implicit non declared dependencies on resources tasks
2022-04-20 08:54:56 +02:00
Chris Hegarty
a2bc4854b5
Fix split package org.elasticsearch.client (#82010)
Fixes split packages between server and the LLRC (and HLRC), by renaming
the server package to a more appropriate name that represents the fact
that is in an internal client. That is, rename server's
org.elasticsearch.client to org.elasticsearch.client.internal.
2021-12-22 17:43:04 +00:00
Chris Hegarty
20c9f756d2
Fix split package org.elasticsearch.common.xcontent (#78831)
Fix the split package org.elasticsearch.common.xcontent, between server and the x-content lib. Move the x-content lib exported package from org.elasticsearch.common.xcontent to org.elasticsearch.xcontent ( following the naming convention of similar libraries ). Removing split packages is a prerequisite to modularization.
2021-10-08 17:14:26 +01:00
Nik Everett
4e0e2f902c
Update versions after backporting #77064 (#77658)
Now that #77064 is backported we can run the bwc tests against it. And
we can speak to 7.16 nodes using the wire protocol addedin #77064.
2021-09-13 16:06:57 -04: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
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
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
Rory Hunter
a5d2251064
Order imports when reformatting (#74059)
Change the formatter config to sort / order imports, and reformat the
codebase. We already had a config file for Eclipse users, so Spotless now
uses that.

The "Eclipse Code Formatter" plugin ought to be able to use this file as
well for import ordering, but in my experiments the results were poor.
Instead, use IntelliJ's `.editorconfig` support to configure import
ordering.

I've also added a config file for the formatter plugin.

Other changes:
   * I've quietly enabled the `toggleOnOff` option for Spotless. It was
     already possible to disable formatting for sections using the markers
     for docs snippets, so enabling this option just accepts this reality
     and makes it possible via `formatter:off` and `formatter:on` without
     the restrictions around line length. It should still only be used as
     a very last resort and with good reason.
   * I've removed mention of the `paddedCell` option from the contributing
     guide, since I haven't had to use that option for a very long time. I
     moved the docs to the spotless config.
2021-06-16 09:22:22 +01:00
Ryan Ernst
68817d7ca2
Rename o.e.common in libs/core to o.e.core (#73909)
When libs/core was created, several classes were moved from server's
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates #73784
2021-06-08 09:53:28 -07:00
Christoph Büscher
5315ed6c32
Fix range queries on runtime double field (#71915)
DoubleScriptFieldRangeQuery which is used on runtime fields of type "double"
currently uses simple double type comparison for checking its upper and lower
bounds. Unfortunately it seems that -0.0 == 0.0, but when we want to exclude a
0.0 bound via "lt" the generated range query uses -0.0 as its upper bound which
erroneously includes the 0.0 value. We can use `Double.compare` instead which
seems to handle this edge case well.

Closes #71786
2021-04-20 16:44:45 +02:00
Alan Woodward
ee3510b766
Add index-time scripts to geo_point field mapper (#71861)
This commit adds the ability to define an index-time geo_point field
with a script parameter, allowing you to calculate points from other
values within the indexed document.
2021-04-20 10:24:25 +01:00
Luca Cavanna
ee5cd443c4
Unify supported runtime fields script contexts (#71833)
There's a few places where we need to access all of the supported runtime fields script contexts. Up until now we have listed them in all those places, but a better way would be to have them listed in one place and access that same list from all consumers. This is what this commit introduces.

Along with the introduction of runtime fields contexts in ScriptModule, we rename the whitelist files so that they contain their corresponding context name to simplify looking them up.
2021-04-19 17:23:59 +02:00
Alan Woodward
05551dd77b
Add index-time scripts to date field mapper (#71633)
This commit allows you to set 'script' and 'on_script_error' parameters
on date field mappers, meaning that runtime date fields can be made indexed
simply by moving their definitions from the runtime section of the mappings
to the properties section.
2021-04-14 09:18:05 +01:00
Alan Woodward
67db2538f8
Add index-time scripts to IP field mapper (#71617)
This commit allows you to set 'script' and 'on_script_error' parameters
on IP field mappers, meaning that runtime IP fields can be made indexed
simply by moving their definitions from the runtime section of the mappings
to the properties section.
2021-04-13 13:40:10 +01:00
Alan Woodward
5e11709693
Add scripts to keyword field mapper (#71555)
This commit adds script and on_script_error parameters to
keyword field mappers, allowing you to define index-time scripts
for keyword fields.
2021-04-12 16:46:02 +01:00
Luca Cavanna
1469e18c98
Add support for script parameter to boolean field mapper (#71454)
Relates to #68984
2021-04-12 10:04:12 +02:00
Christoph Büscher
a413ae67e3
Propagate index errors in field_caps (#70245)
Currently we don't report any exceptions occuring during field_caps requests back to the user.
This PR adds a new failure section to the response which contains exceptions per index. 
In addition the response contains another field, `failed_indices`, with the number of indices that threw
an exception. If all of the requested indices fail, the whole request fails, otherwise the request succeeds 
and it is up to the caller to check for potential errors in the response body.

Closes #68994
2021-04-06 12:02:24 +02:00
Jake Landis
279fde375e
Apply REST API compatibility testing for the :modules (#71137) 2021-04-02 11:20:54 -05:00
Alan Woodward
1653f2fe91
Add script parameter to long and double field mappers (#69531)
This commit adds a script parameter to long and double fields that makes
it possible to calculate a value for these fields at index time. It uses the same
script context as the equivalent runtime fields, and allows for multiple index-time
scripted fields to cross-refer while still checking for indirection loops.
2021-03-31 11:14:11 +01:00
Alan Woodward
c475fd9e8a
Move runtime fields classes into common packages (#70965)
Runtime fields currently live in their own java package. This is really
a leftover from when they were in their own module; now that they are
in core they should instead live in the common packages for classes of
their kind.

This commit makes the following moves:
org.elasticsearch.runtimefields.mapper => org.elasticsearch.index.mapper
org.elasticsearch.runtimefields.fielddata => org.elasticsearch.index.fielddata
org.elasticsearch.runtimefields.query => org.elasticsearch.search.runtime

The XFieldScript fields are moved out of the `mapper` package into 
org.elasticsearch.scripts, and the `PARSE_FROM_SOURCE` default scripts
are moved from these Script classes directly into the field type classes that
use them.
2021-03-29 12:02:01 +01:00
Luca Cavanna
7ee55a7232
Move runtime fields yaml tests to runtime-fields-common module (#69790)
The runtime fields yaml tests are part of the x-pack yaml test suite, but the runtime fields code has been moved to server. This commit moves the yaml tests to the runtime-fields-common module. The reason why all the tests are moved to the module (rather than only the grok and dissect one which the module provides) is that painless is not available in the ordinary yaml tests and these tests rely on painless heavily.

The only tests that are left behind are the telemetry ones, as telemetry is the last bit that needs to be migrated.
2021-03-02 15:19:12 +01:00
Luca Cavanna
a46977f8cd
Move grok and dissect runtime fields to specific module (#69673)
As a follow-up of moving runtime fields to server, we'd like to remove the xpack plugin portions that are left. One part of this is the grok and dissect implementation which depends on grok and dissect libraries that painless does not have available. A new runtime-fields-common module is created to hold their implementations and plug in the necessary whitelists.
2021-03-02 10:08:24 +01:00