Commit graph

279 commits

Author SHA1 Message Date
Rene Groeschke
4d17b2193a
Update Gradle wrapper to 8.12 (#118683) (#119357)
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/DockerCloudElasticsearchDistributionType.java
#	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
#	server/src/main/java/org/elasticsearch/inference/ChunkingOptions.java
#	x-pack/plugin/kql/build.gradle
#	x-pack/plugin/migrate/build.gradle
#	x-pack/plugin/security/qa/security-basic/build.gradle
2024-12-31 08:37:28 +01: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
Patrick Doyle
35a375329a
Move Guice to org.elasticsearch.injection.guice (#111723)
* Move files and fix imports & module exports
* Other consequences of moving Guice
2024-08-12 10:47:46 -04:00
Armin Braun
54ca10e130
Delete unused response deserialization code (#107181)
With the transport client gone, lots of these constructors have become
unused. Removing this dead code also allows making a lot of fields final
as an added bonus.
2024-04-08 06:40:04 -04:00
Armin Braun
8022943c76
Move SearchHit parsing to test codebase (#106787)
Same as the other moves of parser code, this is only used in tests,
no need to have all of this code loaded in production.
2024-03-27 11:01:48 +01:00
Jack Conradson
b5828fbb67
Add plumbing to check cluster features in SearchSourceBuilder (#105417)
This change adds additional plumbing to pipe through the available cluster features into 
SearchSourceBuilder. A number of different APIs use SearchSourceBuilder so they had to make this 
available through their parsers as well often through ParserContext. This change is largely mechanical 
passing a Predicate into existing REST actions to check for feature availability.

Note that this change was pulled mostly from this PR (#105040).
2024-02-13 08:30:04 -08:00
Dmitry Cherniachenko
e21a4874ab
Use String.replace() instead of replaceAll() for non-regexp replacements (#105127)
* Use String.replace() instead of replaceAll() for non-regexp replacements

When arguments do not make use of regexp features replace() is a more efficient option, especially the char-variant.
2024-02-12 13:11:15 -05:00
Armin Braun
5c8006499a
Move test-only search response x-content-parsing code to test codebase (#105308)
Loads of code here that is only used in tests and one duplicate unused
class that was only used as an indirection to parsing the
`AsyncSearchResponse`. Moved what I could easily move via automated
refactoring to `SearchResponseUtils` in tests and removed the duplicate
now unused class from the client codebase.
2024-02-09 11:56:39 +01:00
Armin Braun
81f0c206d1
Fix search response leaks in rank eval tests (#105014)
It's in the title. Somehow none of these tests were leak-proof.
Moving the responses to unpooled to fix things.

closes #104570
2024-02-01 21:24:25 +01:00
Ryan Ernst
b67f5a6b57
Make cluster feature predicate available to plugins (#105022)
A predicate to check whether the cluster supports a feature is available
to rest handlers defined in server. This commit adds that predicate to
plugins defining rest handlers as well.
2024-02-01 09:11:18 -08:00
Dianna Hohensee
8ef5bb5c77
Mute RatedRequestsTests.testSuggestionsNotAllowed (#104990) 2024-01-31 14:58:41 -05:00
Simon Cooper
4567a84c8d
Mute more tests that tend to leak searchhits (#104922) 2024-01-30 15:08:47 +00:00
Jan Kuipers
583d74a8e2
Mute tests that regularly leak SearchHits (#104853)
* Mute TransportRankEvalActionTests.testTransferRequestParameters

* Mute RatedRequestsTests.testXContentParsingIsNotLenient

* Only mute on Windows
2024-01-30 10:38:17 +01:00
David Turner
1116889819
Remove unused arg from ActionType ctor (#104650)
`ActionType` represents an action which runs on the local node, there's
no need for implementations to define a `Reader<Response>`. This commit
removes the unused constructor argument.
2024-01-25 03:28:32 -05:00
Armin Braun
73a68409c2
Ref count search response bytes (#103763)
Final step in  #102030 ... actually makes `SearchHit` read a releasable bytes reference.
Does still fallback to copying to unrolled buffers here and there which can be removed in follow-ups where it's worth the effort (aggs being the most important one probably).

Hard to create very reliable benchmarks for this because all our macro-benchmarks are quite noisy. Running http logs and PMC though, there's a statistically significant reduction in GC and reduced tail latencies in most benchmarks.

The overhead for ref-counting these bytes isn't visible in profiling as far as I can tell and for large source values, no corresponding large `byte[]` are created any longer outside of the few remaining spots where we copy to pooled buffers.

closes #102657
closes #102030
2024-01-17 16:16:39 +01:00
Armin Braun
a3db0c7d57
Move more XContent parser code that is test-only into test module (#104338)
Just another round of #104261
2024-01-16 13:14:12 +01:00
Simon Cooper
016c778321
Remove NamedWriteableRegistry from NodeClient, pass it directly through to rest actions (#103277) 2024-01-11 12:42:22 +00:00
David Turner
af916a0549
Rename StreamInput#readGenericMap (#104045)
`StreamInput#readMap()` is quite different from the other `readMap`
overloads, and pairs up with `StreamOutput#writeGenericMap`. This commit
renames it to avoid accidental misuse and so that the names line up
better between writer and reader.
2024-01-08 08:05:53 -05:00
Armin Braun
c8209ae47c
Make SearchHit have a single primary constructor (#103961)
Making this class ref-counted is rather complicated due to its
mutability. As a first step towards a clean solution, move to a single
primary constructor and make more fields `final`. Also this slightly
speeds up and saves memory on deserialisation by not having to create
the fields maps twice.

part of #102030
2024-01-05 12:21:42 -05:00
Armin Braun
36f08ea441
Make use of constants and utility methods to build empty SearchHits instances (#103983)
This are to be made ref-counted shortly. There's no point in having any
pooling/leak-tracking for empty instances though. To prepare for that,
lets add some short-cuts for dealing with empty instances to make the
overall change smaller and cleanup code already.
2024-01-05 17:43:06 +01:00
Armin Braun
d68670fb88
Inline ActionType in RequestBuilder constructors (#102800)
These are always constant values. We can inline them everywhere to save
code and easy removing the subclasses of ActionType going forward.
2023-11-30 17:57:31 +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
William Brafford
8e6e0e59ea
Make some classes final to avoid suppressing "this-escape" warning (#101699)
* Avoid "this-escape" by making classes final

The "this-escape" compiler warning is intended to alert
developers to potential bugs in object initialization due to
subclassing. This class of bugs cannot occur when a class is
final. Here, we take cases where a class has no implementations
but generates a "this-escape" warning, and we make those
classes final rather than suppressing the compiler warning.
This makes the remaining suppressions more meaningful, since
they now indicate places where we may want to look for
initialization bugs.

In a few cases, making a class final meant changing some of its
protected fields and methods to private or default
accessibility.

Some classes with no implementations are mocked in testing.
Since making those classes final would involve non-trivial
rewrites of tests, I've left them alone.

* Spotless, remove redundant modifiers, clean up "protected" usage

* Revert a few more mocked classes
2023-11-02 08:34:02 -04:00
David Turner
3ce905b754
Remove more unnecessary ActionType subclasses (#101053)
Relates #97721
2023-10-18 13:56:40 +01:00
David Turner
0a31ce64a9
Remove dangerous default executor from HandledTransportAction (#100162)
Today subclasses of `HandledTransportAction` can specify the executor on
which they run, but the executor is optional and if omitted will use
`DIRECT_EXECUTOR_SERVICE`, which means the action runs on a transport
thread. This is a dangerous default behaviour because it makes it easy
to add new transport actions which implicitly run on a network thread,
which is very hard to pick up in reviews.

This commit makes the executor explicit in all callers, and marks the
dangerous methods for removal.
2023-10-03 17:54:52 -04:00
Tim Vernum
d411acecbc
Suppress this-escape warning for JDK21 (#99848)
Adds @SuppressWarnings("this-escape") to all necessary places to that
Elasticsearch can compile with -Werror on JDK21

No investigation has been done to determine whether any of the cases
are a potential source of errors - we have simply suppressed all
existing occurrences.

Resolves: #99845
2023-09-25 18:30:21 +10:00
Dianna Hohensee
f69c5b1460
Call TransportService#registerRequestHandler with Executor (#99385)
Remove temporary TransportService#registerRequestHandler functions
that take String instead of Executor and update the callers. This
is part of a larger change to pass Executor into request handlers,
rather than creating and stashing Strings that are only used to
eventually fetch appropriate Executors anyway.

Extensive testing changes were required to make TransportService and
ThreadPool mocks capable of looking up Executors from Strings for
TransportAction constructors. Added a new MockUtils class to
modularize the additional test setup.

Part of the changes for #97879
2023-09-08 17:12:40 -04:00
Dianna Hohensee
7433b5122c Revert "Call TransportService#registerRequestHandler with Executor (#98998)"
This reverts commit df38bc8a84.
2023-09-08 13:40:21 -04:00
Dianna Hohensee
df38bc8a84
Call TransportService#registerRequestHandler with Executor (#98998)
Remove temporary TransportService#registerRequestHandler functions
that take String instead of Executor and update the callers. This
is part of a larger change to pass Executor into request handlers,
rather than creating and stashing Strings that are only used to
eventually fetch appropriate Executors anyway.

Extensive testing changes were required to make TransportService and
ThreadPool mocks capable of looking up Executors from Strings for
TransportAction constructors. Added a new MockUtils class to
modularize the additional test setup.

Part of the changes for #97879
2023-09-08 13:21:53 -04:00
Ryan Ernst
19257125b1
Move transport version constants to TransportVersions (#97990)
Constants for TransportVersion currently live alongeside the class
definition. This has been fine since there was only one set of
constants. However, to support serverless, some constants will need to
be defined elsewhere.

This commit moves the existing constants to a new holder class,
TransportVersions. It is almost entirely mechanical, using IntelliJ move
members. The only non mechanical part was slightly shifting how CURRENT
is found, defining a LATEST in TransportVersions that is automatically
calculated (since we already have it, no need to manually define it).
2023-09-06 15:14:41 -04:00
David Turner
1e9c7f1d95
Align collection de/serialization API naming (#99150)
The `StreamOutput` and `StreamInput` APIs are designed so that code
which serializes objects to the transport protocol aligns closely with
the corresponding deserialization code. However today
`StreamOutput#writeCollection` pairs up with a variety of methods on
`StreamInput`, including `readList`, `readSet`, and so on. These methods
are not obviously compatible with `writeCollection` unless you look at
the implementation, and that makes verifying transport protocol code
harder than it needs to be.

This commit renames these methods to `readCollectionAsList`,
`readCollectionAsSet`, and so on, to clarify that they are compatible
with `writeCollection`.

Relates
https://github.com/elastic/elasticsearch/pull/98971#issuecomment-1697289815
2023-09-04 06:46:54 -04:00
Armin Braun
dea8890c50
Dry up Writeable.writeTo lambda usage around StreamOutput (#99143)
No need to duplicate the lambda all over the place.
Follow-up to #99087
2023-09-03 10:35:22 +02: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
Armin Braun
63e64ae61b
Cleanup Stream usage in various spots (#97306)
Lots of spots where we did weird things around streams like redundant stream creation, redundant collecting
before adding all the collected elements to another collection or so, redundant streams for joining strings
and using less efficient `Collectors.toList` and in a few cases also incorrectly relying on the result being mutable.
2023-07-03 14:24:57 +02:00
Armin Braun
1a34568a8b
Remove remaining redundant overrides (#97134)
Follow-up to #97130, removing all remaining redundant overrides outside
the server package.
2023-06-27 13:08:13 +02: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
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
Keith Massey
7692e4df65
Adding initial public and internal serverless scopes to Search team REST handlers (#94035) 2023-03-10 08:30:29 -06:00
David Turner
e1ad46baaa
Hide internal details of ActionListener impls (#94320)
The `ActionListener` interface implements its static methods using
various inner classes. These inner classes are public because interfaces
do not support package-private inner classes, although they are `final`
and only have `protected` constructors which prevent anyone else from
instantiating them. It's certainly a mistake for code in other packages
to access these things.

This commit moves the implementation details into a separate class to
hide them from the rest of the world. It also tightens up the calls to
`onFailure()` in a few places to better handle the possibility of this
method throwing an exception. Finally, it moves
`DelegatingActionListener` to a top level public class since this
utility is used in quite a number of places.
2023-03-07 04:04:24 -05:00
Simon Cooper
6071c769fb
Migrate indices package to TransportVersion (#93077)
This migrates org.elasticsearch.index and org.elasticsearch.indices to use TransportVersion
2023-01-25 13:21:43 +00:00
Artem Prigoda
2bc7398754
Use Strings.format instead of String.format(Locale.ROOT, ...) in tests (#92106)
Use local-independent `Strings.format` method instead of `String.format(Locale.ROOT, ...)`. 
Inline `ESTestCase.forbidden` calls with `Strings.format` for the consistency sake.
Add `Strings.format` alias in `common.Strings`
2023-01-03 19:28:27 +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
Christoph Büscher
e53a0f8028
Remove unused SearchParseException (#92446)
This exception is only used as random exception in tests and isn't used in
production code since 7.11, so we should remove it. ParsingException or
XContentParseException are preferred choices when parsing location for errors is
available.
2022-12-20 23:46:03 +01:00
Luca Cavanna
238163cd60
Expose telemetry about search usage (#91528)
This is the continuation of #90176 which leverages #90425 to count query types. This PR adds search usage stats to the existing telemetry by counting sections being used as part of a search request, as well as query types. Each distinct query type is counted once per search request.

The counting is performed while parsing, for the following REST search endpoints:

- _search
- _msearch
- _async_search
- _search/template
- _msearch/template
- _fleet/_fleet_search
- _fleet/_fleet_msearch

All other API using search internally, like reindex, ML transform, rank eval, sql etc. are not counted as part of these search usage stats. Such additional functionalities should have its own dedicated telemetry if needed.

The counting of the search sections is not extensive, only the ones that are interesting to collect counts for are tracked.

The following is the new section added to the cluster stats API response, including some sample stats:

```
"search" : {
  "total" : 63,
  "sections" : {
    "knn" : 42,
    "query" : 21, 
    "aggs" : 46
  }, 
  "query" : {
    "match" : 58
  }
}
```

A big part of the change is actually the plumbing to make a common service class that holds the counters available to all the different callers of the parsing methods, especially plugins. Ideally, there would be a separate component that exposes the search parsing functionality rather than static methods, but changing that would require making the additional component available to the REST layer which is not trivial. I reused the existing UsageService which the RestController already holds, and is already used to count access to the different REST endpoints.

Co-authored-by: Mayya Sharipova mayya.sharipova@elastic.co
2022-11-15 21:34:49 +01:00
Alan Woodward
547c8327b2
Allow FetchSubPhaseProcessors to report their required stored fields (#91269)
Loading of stored fields is currently handled directly in FetchPhase, with
some fairly complex logic examining various bits of the FetchContext to work
out what fields need to be loaded. This is further complicated by synthetic
source, which may have its own stored field requirements.

This commit tries to separate out these concerns a little by adding a new
StoredFieldsSpec record that holds information about which stored fields
need to be loaded. Each FetchSubPhaseProcessor can now report a
StoredFieldsSpec detailing what its requirements are, and these specs can
be merged together, along with requirements from a SourceLoader, to
determine up-front what fields should be loaded by the StoredFieldLoader.
The stored fields themselves are added into the SearchHit by a new
StoredFieldsPhase, which handles alias resolution and value post-
processing. The logic to determine when source should be loaded and
when not, based on the presence of script fields or stored fields, is
moved into FetchContext, which highlights some inconsistencies that
can be fixed in follow-up commits.
2022-11-10 08:40:22 +00:00
Albert Zaharovits
af537cc4a3
Fix index expression options for requests with a single expression (#91231)
This PR affects requests that contain a single index name
or a single pattern (wildcard/datemath).
It aims to systematize the handling of the `allow_no_indices`
and `ignore_unavailable`indices options:
 * the allow_no_indices option is to be concerned with
wildcards that expand to nothing (or the entire request
expands to nothing)
 * the ignore_unavailable option is to be concerned with
explicit names only (not wildcards)

In addition, the behavior of the above options will now be
independent of the number of expressions in a request.
2022-11-04 18:11:12 +02:00
Rene Groeschke
43a0377735
Update forbiddenapis to 3.4 (#90624)
Fix breaking changes to source validation after change in default jdk rule set
2022-10-06 16:52:06 +02:00
Armin Braun
00b3721108
Dry up collection writing to StreamOutput (#86386)
Small weekend project around automated refactoring:
We have endless duplication here, drying up some of it.
2022-05-24 07:30:34 +02:00