Commit graph

91 commits

Author SHA1 Message Date
Rene Groeschke
20a78a18e9
[8.17] [Gradle] Remove static use of BuildParams (#115122) (#117433)
* [Gradle] Remove static use of BuildParams (#115122)

Static fields dont do well in Gradle with configuration cache enabled.

- Use buildParams extension in build scripts
- Keep BuildParams.ci for now for easy serverless migration
-  Tweak testing doc

(cherry picked from commit 13c8aaeffa)

# Conflicts:
#	TESTING.asciidoc
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java
#	build.gradle
#	modules/ingest-geoip/qa/full-cluster-restart/build.gradle
#	qa/mixed-cluster/build.gradle
#	x-pack/plugin/ent-search/qa/full-cluster-restart/build.gradle
#	x-pack/plugin/eql/qa/rest/build.gradle
#	x-pack/plugin/fleet/qa/rest/build.gradle
#	x-pack/plugin/kql/build.gradle
#	x-pack/plugin/mapper-unsigned-long/build.gradle
#	x-pack/plugin/ml/qa/multi-cluster-tests-with-security/build.gradle
#	x-pack/plugin/security/qa/multi-cluster/build.gradle
#	x-pack/plugin/sql/qa/jdbc/build.gradle
#	x-pack/plugin/transform/qa/multi-cluster-tests-with-security/build.gradle

* Some cleanup

* Update build.gradle

fix buildparams access
2024-11-25 18:29:26 +01:00
Mark Vieira
0279c0a909
Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
Kostas Krikellas
f3bc281978
Refactor build params for FieldMapper, adding SourceKeepMode (#112455)
* Refactor build params for FieldMapper

* more mappers and tests

* more mappers

* more mappers

* spotless

* spotless

* stored by default

* Revert "stored by default"

This reverts commit bbd247d64b.

* restore storeIgnored

* sync

* list valid values for SourceKeepMode

* small refactoring

* spotless
2024-09-06 14:16:17 +03:00
Ignacio Vera
7eab0e89a6
Remove unused GeoShapeFieldMapper from server (#110689) 2024-07-10 16:04:42 +02:00
Luca Cavanna
915e4a50c5
Rename Mapper#name to Mapper#fullPath (#110040)
This addresses a long standing TODO that caused quite a few bugs over time, in that the mapper name does not include its full path, while the MappedFieldType name does.

We have renamed Mapper.Builder#name to leafName (#109971) and Mapper#simpleName to leafName (#110030). This commit renames Mapper#name to fullPath for clarity
This required some adjustments in FieldAliasMapper to avoid confusion between the existing path method and fullPath. I renamed path to targetPath for clarity.
ObjectMapper already had a fullPath method that returned name, and was effectively a copy of name, so it could be removed.
2024-06-21 22:47:27 +02:00
Luca Cavanna
54e7b4d93b
Rename Mapper#simpleName to Mapper#leafName (#110030)
This addresses a long standing TODO that caused quite a few bugs over time, in that the mapper name does not include its full path, while
the MappedFieldType name does. We have method called simpleName to signal that, but leafName signals that more clearly and aligns with
the name we have recently introduced in Mapper.Builder (renamed from name to leafName).

Relates to #109971
2024-06-21 14:28:36 +02:00
Luca Cavanna
15c7abe111
Rename Mapper#name to Mapper#leafName (#109971)
This addresses a long standing TODO that caused quite a few bugs over time, in that the mapper name does not include its full path, while
the MappedFieldType name does.
2024-06-21 11:48:17 +02:00
Oleksandr Kolomiiets
5440f178aa
Support synthetic source for geo_point when ignore_malformed is used (#109651) 2024-06-18 08:37:27 -07:00
Felix Barnsteiner
5920c917aa
Encapsulate Mapper.Builder#name and make it private (#105648)
This is in preparation to make the field mutable,
which is needed in the context of https://github.com/elastic/elasticsearch/pull/103542
2024-02-20 15:53:14 +01:00
Felix Barnsteiner
ff0f83f59d
Make field limit more predictable (#102885)
Today, we're counting all mappers, including mappers for subfields that
aren't explicitly added to the mapping towards the field limit.

This means that some field types, such as `search_as_you_type` or
`percolator` count as more than one field even though that's not
apparent to users as they're just defining them as a single field in the
mapping.

This change makes it so that each field mapper only counts as one. We're
still counting multi-fields.

This makes it easier to understand for users why the field limit is hit.

~In addition to that, it also simplifies
https://github.com/elastic/elasticsearch/pull/96235 as it makes the
implementation of `Mapper.Builder#getTotalFieldsCount` much easier and
easier to align with `Mapper#getTotalFieldsCount`. This reduces the risk
of over- or under-estimating the field count of a `Mapper.Builder` in
`DocumentParserContext#addDynamicMapper`, which in turn reduces the risk
of data loss due to the issue described here:
https://github.com/elastic/elasticsearch/pull/96235#discussion_r1402495749.~

*Edit: due to https://github.com/elastic/elasticsearch/pull/103865, we
don't need an implementation of `getTotalFieldsCount` or `mapperSize` in
`Mapper.Builder`. Still, this PR more closely aligns
`Mapper#getTotalFieldsCount` with `MappingLookup#getTotalFieldsCount`,
which  `DocumentParserContext#addDynamicMapper` uses to determine
whether the field limit is hit*

A potential risk of this is that we're now effectively allowing more
fields in the mapping. It may be surprising to users that more fields
can be added to a mapping. Although, I'd not expect negative
consequences from that. Generally, I'd  expect users to be happy about
any change that reduces the risk of data loss.

We could also think about whether to apply the new counting logic only
to new indices (depending on the `IndexVersion`). However, that would
add more complexity and I'm not convinced about the value. We'd then
need to maintain two different ways of counting fields and also require
passing in the `IndexVersion` to `MappingLookup` which previously didn't
require the `IndexVersion`.

This PR is meant as a conversation starter. It would also simplify
https://github.com/elastic/elasticsearch/pull/96235 but I don't think
this blocks that PR in any way.

I'm curious about the opinion of @javanna and @jpountz on this.
2024-02-06 06:58:42 -05:00
Armin Braun
a72524a996
Remove some more unused XContent parsers (#98070)
Remove some more of these parsers that have become obsolete with the
HLRC going away.
2024-01-08 15:38:18 +01:00
Armin Braun
cca24c1c5d
Fix search response leaks in datastreams and mustache modules (#103532)
Fixes the remaining test leaks in datastream and mustache. Mustache will
require a separate PR to make the search template response classes
properly ref-counted but we can prepare for that here already.

for https://github.com/elastic/elasticsearch/issues/102030
2023-12-19 06:15:57 -05:00
Armin Braun
49f1b5b787
Make sure to close XContentParser in more spots (#103504)
We're leaking quite a few of these parsers. That doesn't seem to be much
of a problem but results in some memory inefficiencies in Jackson here
and there. This PR bulk fixes a bunch of instances that I could easily
automatically fix. I'll open a follow-up for closing the parser on the
document parsing context which also suffers from this but is non-trivial
to fix.
2023-12-19 10:26:06 +01:00
Armin Braun
1b84ea7421
Delete all unused private methods (#98111)
Pretty straight forward dead-code cleanup I think. Just delete all
private methods or methods in private classes that aren't used.
2023-11-25 22:21:59 +01:00
Armin Braun
cdc83ad29b
Add shorthand for prepareIndex to test infrastructure (#101187)
Same as #101175, shorten `client().prepareIndex(index)` and
`client().prepareIndex().setIndex(index)` via a test utility.
Saves lots of code now and sets up some follow-up simplifcations.
2023-11-23 15:47:36 +01:00
Ignacio Vera
8a9f4fed55
Remove explicit SearchResponse references from LegacyGeo, Aggregations and parent-join modules (#101250) 2023-10-24 17:46:25 +02:00
Armin Braun
3945ee75d0
Use assertAcked more (#101201)
Just found that we have a lot of inconsistency and needless verbosity
here in tests. We can just use `assertAcked` in a couple spots
to save `.get`, `.actionGet` etc., especially with the signature
change I added here.
2023-10-23 19:48:10 +02:00
David Turner
1eda6ac74b
Extract ESIntegTestCase#prepareSearch (#101175)
Relates #101172
2023-10-20 06:18:58 -04:00
Ryan Ernst
8a1db8c6c3
Move index version constants to IndexVersions (#101094)
Similar to the TransportVersions holder class, IndexVersions is the new
place to contain all constants for IndexVersion. This commit moves all
existing constants to the new class. It is purely mechanical.
2023-10-19 20:44:51 -04:00
Ignacio Vera
9fb550be44
WellKnownBinary#toWKB should not throw an IOException (#100669)
The only reason this method is throwing an exception is because the
method ByteArrayOutputStream#close() is declaring it although it is a
noop. Therefore it can be safely ignored.

Thanks @romseygeek for bringing into attention.
2023-10-11 08:24:32 -04:00
Armin Braun
b7eafce32c
Make some practically static methods static (#97565)
Another round of automated fixes to this, marking things that can be
made static as static. Saves some JIT cycles but also turns some lambdas
from capturing to non-capturing and makes the "utilityness" of some
classes visible.
2023-10-06 23:37:07 +02:00
Alan Woodward
4e1fb3fca5
Automatically disable ignore_malformed on datastream @timestamp fields (#99346)
Data-stream mappings require a @timestamp field to be present and configured
as a date with a specific set of parameters. The index-wide setting of
ignore_malformed can cause problems here if it is set to true, because it needs
to be false for the @timestamp field.

This commit detects if a set of mappings is configured for a datastream by checking
for the presence of a DataStreamTimestampFieldMapper metadata field, and passes
that information on during Mapper construction as part of the MapperBuilderContext.
DateFieldMapper.Builder now checks to see if it is specifically for a data stream timestamp
field, and if it is, sets ignore_malformed to false.

Relates to #96051
2023-09-13 15:02:22 +01:00
Armin Braun
f1a376c317
Remove CopyTo.Builder (#99368)
The copyTo builder is really hard to reason about when it comes to
mapper merging, because the `reset` method would actually mutate an
existing mapper. That seems dangerous and the whole thing is quite
inefficient as well. -> this PR just removes it and uses a copy
constructor for copy on write, avoiding instance creation on mapper
merges here and there and leaving no doubt about these things being
immutable.
2023-09-08 13:24:31 -04:00
Armin Braun
97ebcea5c2
Dry up writing string collections via StreamOutput (#99087)
We can dry up and shorten a bunch of spots by using the overloads
we already have in the code. Also, added a new overload for writing a
map with string keys.
2023-09-02 11:09:43 +02:00
Armin Braun
e4de4021fc
Remove redundant writeList from StreamOutput (#98971)
Noticed this when benchmarking FieldCaps transport messages.
The `writeList` alias just adds more lines to the code and makes
profiling more annoying to read, lets remove it.
2023-08-29 16:00:59 +02:00
Matteo Piergiovanni
e719057209
Explicit parsing object capabilities of FieldMappers (#98684)
When the subobject property is set to false and we encounter an object 
while parsing we need a way to understand if its FieldMapper is able to 
parse an object. If that's the case we can provide the entire object to 
the FieldMapper otherwise its name becomes the part of the dotted field
name of each internal value.

This has being achieved by adding the `supportsParsingObject()` method 
to the `FieldMapper` class. This method defaults to `false` since the 
majority of FieldMappers do not support parsing objects and is 
overwritten to return `true` by the ones that do support objects.
2023-08-22 10:16:59 +02:00
Simon Cooper
5271b9a9e9
Refactor some uses of randomIndexCompatibleVersion to use IndexVersion (#98032) 2023-08-21 10:09:55 +01:00
Simon Cooper
c78eef86fa
Refactor non-testcase uses of index created version with release version (#98007)
Change uses of Version to IndexVersion to specify the index created version
2023-07-27 15:31:19 +01:00
Simon Cooper
532e346e4a
Some more migrations of Version to IndexVersion (#97363) 2023-07-10 11:40:32 +01:00
Simon Cooper
5728d15d15
Migrate geoshape tests to IndexVersion (#97365) 2023-07-05 09:07:10 +01:00
Simon Cooper
a873e26cf7
Convert IndexVersion.CURRENT to a method with a pluggable interface (#97132) 2023-06-27 14:47:32 +01:00
Armin Braun
3f8ee82ef8
Use indices admin client shortcut in most integration tests (#96946)
Replacing the remaining usages that I could automatically replace
and a couple that I did by hand in this PR.
Also, added the same shortcut to the single node tests to save some
duplication there.
2023-06-20 13:32:59 +02:00
Simon Cooper
71c12262fb
Migrate index created version to IndexVersion (#96066) 2023-06-14 09:43:31 +01:00
David Turner
c5e519dcd8
Remove unnecessary != false idioms (#96654) 2023-06-07 10:12:51 -04:00
Armin Braun
c41bda9e3a
Dry up remaining verbose index setting building in tests (#95652)
Lasts spots I could easily find via regex.
Follow-up to #95569
2023-04-28 11:18:07 +02:00
Simon Cooper
0c528cc778
Convert some uses of coll.toArray(coll.size()) to coll.toArray(Type[]::new) (#94816) 2023-04-17 10:11:42 +01:00
Alan Woodward
093e36c875
Introduce DocumentParsingException (#92646)
Document parsing methods currently throw MapperParsingException. This
isn't very helpful, as it doesn't contain any information about where the parse
error happened - it is designed for parsing mappings, which are realised into
java maps before being examined. This commit introduces a new exception
specifically for document parsing that extends XContentException, so that
it reports the current position of the parser as part of its error message.

Fixes #85083
2023-03-31 12:14:19 +01:00
Simon Cooper
56d53da381
Migrate LuceneDocument.getFields(String) to a List (#94830) 2023-03-29 11:08:36 +01:00
David Turner
6da721edda
Assert TaskTransportChannel completed once (#94598) 2023-03-21 13:56:45 -04:00
Alan Woodward
41ab45a5d9
Report synthetic source status in MapperBuilderContext (#91400)
We currently work out whether or not a mapper should be storing additional
values for synthetic source by looking at the DocumentParserContext. However,
this value does not change for the lifetime of the mapper - it is defined by
metadata on the root mapper and is immutable - and DocumentParserContext
feels like the wrong place for this information as it holds context specific
to the document being parsed.

This commit moves synthetic source status information from DocumentParserContext
to MapperBuilderContext instead. Mappers which need this information retrieve
it at build time and hold it on final fields.
2022-11-08 14:55:16 +00:00
Luca Cavanna
d37cae2fa4
Consolidate field name validation when parsing mappings and documents (#91328)
#91043 surfaced some inconsistencies in field names validation between mapping parsing and document parsing. This commit centralizes the validation of field names when parsing mappings to a single place, and attempts to address some of the inconsistencies.

 - field names that contain only whitespaces are no longer accepted in mappings. It was previously possible to map a field containing only whitespaces but a document containing such a field would be rejected. We start rejecting mappings with fields that contain only whitespaces for indices that are created from 8.6 on, just in case existing indices contain such fields. This is true also for dotted fields like top. .foo when subobjects are enabled.

 - A clear error message is thrown when mappings hold fields with names made of dots only. An ArrayIndexOutOfBoundsException was thrown before

 - The error thrown when a field name is empty is now unified with that thrown when an empty field name is provided as part of a document (field name cannot be an empty string)

 - When parsing documents (with subobjects set to false), distinguish between the error thrown when a field name is empty and that thrown when a field name is made of whitespaces only

 - When parsing documents (with subobjects set to false), accept field names that are made of dots only (these are already accepted in mappings), effectively reverts #90950
2022-11-07 13:29:29 +01:00
Nik Everett
bc49392bfb
Support malformed numbers in synthetic _source (#90428)
This adds support for `ignore_malformed` to numeric fields other than
`scaled_float` in synthetic `_source`. Their values are saved to a
stored field and loaded to render the `_source`.
2022-10-04 12:17:30 -04:00
Nik Everett
f4fad2548f
Always support ignore_malformed in the same way (#90565)
This makes sure that all field types that support `ignore_malfored` do
so in the same way.

Production changes:
* All mapper has an `ignoreMalformed` method that must return `true` if
  the field accepts the `ignore_malformed` mapping parameter was
  configured. It defaults to `false` because many fields either don't
  have a concept of "malformed" value or don't have the ability to
  ignore malformed values.
* Fix the `scaled_float` field to store it's field name in `_ignored` if
  it ignores any malfored values. This is how all other field mappers
  work.

Test changes:
* `MapperTestCase` forces subclasses to declare if their
  `supportIgnoreMalformed` or not.
* If `MapperTestCase` subclasses `supportIgnoreMalfored` they must
  define some `exampleMalformedValues`.
* `MapperTestCase` always grows three new tests:
  * One that creates a field without setting `ignore_malformed` and
    verifies that all `exampleMalformedValues` throw expected errors
  * On that explicitly configured `ignore_malformed` to false and, if
    `supportIgnoreMalformed` it verifies the errors again. If not
    `supportIgnoreMalformed` it verifies that the parameter is unknown.
  * On that explicitly configured `ignore_malformed` to true and, if
    `supportIgnoreMalformed` it verifies that parsing doesn't produce
    errors and correctly produces `_ignored`. If not
    `supportIgnoreMalformed` it verifies that the parameter is unknown.
* Moved some subclasesses of `MapperTestCase` from
  `internalClusterTests` to `tests`. This isn't strictly required but
  that's the right place for them.
2022-10-03 06:18:02 -04:00
Rene Groeschke
3909b5eaf9
Add verification metadata for dependencies (#88814)
Removing the custom dependency checksum functionality in favor of Gradle build-in dependency verification support. 

- Use sha256 in favor of sha1 as sha1 is not considered safe these days.

Closes https://github.com/elastic/elasticsearch/issues/69736
2022-08-04 09:51:16 +02:00
Ignacio Vera
ed564f6e1d
Update lo lucene-9.3.0 (#88927) 2022-08-01 07:21:13 +02:00
Ignacio Vera
3b7f393a82
Upgrade to lucene snapshot lucene-9.3.0-snapshot-b8d1fcfd0ec (#88706) 2022-07-22 11:22:39 +02:00
Craig Taverner
6797d44f1a
Support cartesian shape with doc values (#88487)
Shape field type generated doc values by default now.
2022-07-14 07:17:51 +02:00
Ignacio Vera
4af02b8c80
Stop registering TestGeoShapeFieldMapperPlugin in ESIntegTestCase (#88460)
Instead of registering the plugin by default, implementations that need it are responsible on registering the plugin.
2022-07-12 14:42:45 +02:00
Nhat Nguyen
bd69f90fff
Upgrade to Lucene-9.3.0-snapshot-2d05f5c623e (#88284)
To include LUCENE-10620 - which passes Weight to Collector
2022-07-06 16:16:03 -04:00
Nhat Nguyen
c2dc6e6ef4
Upgrade to new Lucene snapshot (#87932)
This PR uses Lucene-9.3 snapshot in Elasticsearch 8.4. Noticeable changes in this Lucene snapshot:

- Merge-on-refresh (disabled)
- No more pathological merging
- SortedSetDocValues#count for value_count aggs
2022-06-23 12:18:27 -04:00