Skip to content

Commit ce5484d

Browse files
Merge branch 'main' into esql/settings_stack_telemetry
2 parents 8b35cf6 + 6679e41 commit ce5484d

File tree

1,043 files changed

+49555
-10285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,043 files changed

+49555
-10285
lines changed

.github/CODEOWNERS

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,20 @@ docs/*.yml @elastic/core-docs
107107
docs/community-clients @elastic/core-docs
108108
docs/release-notes @elastic/core-docs
109109
docs/extend @elastic/admin-docs
110-
docs/java-rest @elastic/dev-docs
110+
docs/java-rest @elastic/developer-docs
111111
docs/reference @elastic/core-docs
112-
docs/reference/aggregations @elastic/dev-docs
113-
docs/reference/community-contributed @elastic/dev-docs
112+
docs/reference/aggregations @elastic/developer-docs
113+
docs/reference/community-contributed @elastic/developer-docs
114114
docs/reference/elasticsearch/command-line-tools @elastic/admin-docs
115-
docs/reference/elasticsearch/index-lifecycle-actions @elastic/dev-docs
116-
docs/reference/elasticsearch/mapping-reference @elastic/dev-docs
117-
docs/reference/elasticsearch/rest-apis @elastic/dev-docs
115+
docs/reference/elasticsearch/index-lifecycle-actions @elastic/developer-docs
116+
docs/reference/elasticsearch/mapping-reference @elastic/developer-docs
117+
docs/reference/elasticsearch/rest-apis @elastic/developer-docs
118118
docs/reference/elasticsearch/elasticsearch-audit-events.md @elastic/admin-docs
119119
docs/reference/elasticsearch/jvm-settings.md @elastic/admin-docs
120120
docs/reference/elasticsearch/roles.md @elastic/admin-docs
121121
docs/reference/enrich-processor @elastic/admin-docs
122-
docs/reference/query-languages @elastic/dev-docs
122+
docs/reference/query-languages @elastic/developer-docs
123123
docs/reference/scripting-languages @elastic/admin-docs
124-
docs/reference/search-connectors @elastic/dev-docs
124+
docs/reference/search-connectors @elastic/developer-docs
125125
docs/reference/setup/install/docker @elastic/admin-docs
126-
docs/reference/text-analysis @elastic/dev-docs
126+
docs/reference/text-analysis @elastic/developer-docs

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# claude
33
.claude
44

5+
# cursor
6+
.cursorrules
7+
58
# JetBrainsAI/Junie
69
.junie/
710

@@ -87,3 +90,6 @@ server/src/main/resources/transport/definitions/manifest.txt
8790

8891
# JEnv
8992
.java-version
93+
94+
# Vector data files
95+
qa/vector/.data

AGENTS.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Elasticsearch
2+
3+
## Toolchain Snapshot
4+
- **Java**: JDK 25 via `JAVA_HOME`; use the bundled Gradle wrapper (`./gradlew`).
5+
- **Build tooling**: Gradle composite build with `build-conventions`, `build-tools`, and `build-tools-internal`; Docker is required for some packaging/tests.
6+
- **OS packages**: Packaging and QA jobs expect ephemeral hosts; do not run packaging suites on your workstation.
7+
- **Security**: Default dev clusters enable security; use `elastic-admin:elastic-password` or disable with `-Dtests.es.xpack.security.enabled=false`.
8+
- **Cursor/Copilot rules**: None provided in repo; follow this guide plus CONTRIBUTING.md.
9+
10+
## Build & Run Commands
11+
- Refer to CONTRIBUTING.md & TESTING.asciidoc for comprehensive build/test instructions.
12+
13+
## Verification & Lint Tasks
14+
- `./gradlew spotlessJavaCheck` / `spotlessApply` (or `:server:spotlessJavaCheck`): enforce formatter profile in `build-conventions/formatterConfig.xml`.
15+
16+
## Project Structure
17+
The repository is organized into several key directories:
18+
* `server`: The core Elasticsearch server.
19+
* `modules`: Features shipped with Elasticsearch by default.
20+
* `plugins`: Officially supported plugins.
21+
* `libs`: Internal libraries used by other parts of the project.
22+
* `qa`: Integration and multi-version tests.
23+
* `docs`: Project documentation.
24+
* `distribution`: Logic for building distribution packages.
25+
* `x-pack`: Additional code modules and plugins under Elastic License.
26+
* `build-conventions`, `build-tools`, `build-tools-internal`: Gradle build logic.
27+
28+
## Testing Cheatsheet
29+
- Standard suite: `./gradlew test` (respects cached results; add `-Dtests.timestamp=$(date +%s)` to bypass caches when reusing seeds).
30+
- Single project: `./gradlew :server:test` (or other subproject path).
31+
- Single class: `./gradlew :server:test --tests org.elasticsearch.package.ClassName`.
32+
- Single package: `./gradlew :server:test --tests 'org.elasticsearch.package.*'`.
33+
- Single method / repeated runs: `./gradlew :server:test --tests org.elasticsearch.package.ClassName.methodName -Dtests.iters=N`.
34+
- Deterministic seed: append `-Dtests.seed=DEADBEEF` (each method uses derived seeds).
35+
- JVM tuning knobs: `-Dtests.jvms=8`, `-Dtests.heap.size=4G`, `-Dtests.jvm.argline="-verbose:gc"`, `-Dtests.output=always`, etc.
36+
- Debugging: append `--debug-jvm` to the Gradle test task and attach a debugger on port 5005.
37+
- CI reproductions: copy the `REPRODUCE WITH` line from CI logs; it includes project path, seed, and JVM flags.
38+
- Yaml REST tests: `./gradlew ":rest-api-spec:yamlRestTest" --tests "org.elasticsearch.test.rest.ClientYamlTestSuiteIT.test {yaml=<relative_test_file_path>}"`
39+
- Use the Elasticsearch testing framework where possible for unit and yaml tests and be consistent in style with other elasticsearch tests.
40+
- Use real classes over mocks or stubs for unit tests, unless the real class is complex then either a simplified subclass should be created within the test or, as a last resort, a mock or stub can be used. Unit tests must be as close to real-world scenarios as possible.
41+
- Ensure mocks or stubs are well-documented and clearly indicate why they were necessary.
42+
43+
### Test Types
44+
- Unit Tests: Preferred. Extend `ESTestCase`.
45+
- Single Node: Extend `ESSingleNodeTestCase` (lighter than full integ test).
46+
- Integration: Extend `ESIntegTestCase`.
47+
- REST API: Extend `ESRestTestCase` or `ESClientYamlSuiteTestCase`. **YAML based REST tests are preferred** for integration/API testing.
48+
49+
## Dependency Hygiene
50+
- Never add a dependency without checking for existing alternatives in the repo.
51+
52+
## Formatting & Imports
53+
- Absolutely no wildcard imports; keep existing import order and avoid reordering untouched lines.
54+
55+
## Types, Generics, and Suppressions
56+
- Prefer type-safe constructs; avoid raw types and unchecked casts.
57+
- If suppressing warnings, scope `@SuppressWarnings` narrowly (ideally a single statement or method).
58+
- Document non-obvious casts or type assumptions via Javadoc/comments for reviewers.
59+
60+
## Naming Conventions
61+
- REST handlers typically use the `Rest*Action` pattern; transport-layer handlers mirror them with `Transport*Action` classes.
62+
- REST classes expose routes via `RestHandler#routes`; when adding endpoints ensure naming matches existing REST/Transport patterns to aid discoverability.
63+
- Transport `ActionType` strings encode scope (`indices:data/read/...`, `cluster:admin/...`, etc.); align new names with these conventions to integrate with privilege resolution.
64+
65+
## Logging & Error Handling
66+
- Elasticsearch should prefer its own logger `org.elasticsearch.logging.LogManager` & `org.elasticsearch.logging.Logger`; declare `private static final Logger logger = LogManager.getLogger(Class.class)`.
67+
- Always use parameterized logging (`logger.debug("operation [{}]", value)`); never build strings via concatenation.
68+
- Wrap expensive log-message construction in `() -> Strings.format(...)` suppliers when logging at `TRACE`/`DEBUG` to avoid unnecessary work.
69+
- Log levels:
70+
- `TRACE`: highly verbose developer diagnostics; usually read alongside code.
71+
- `DEBUG`: detailed production troubleshooting; ensure volume is bounded.
72+
- `INFO`: default-enabled operational milestones; prefer factual language.
73+
- `WARN`: actionable problems users must investigate; include context and, if needed, exception stack traces.
74+
- `ERROR`: reserve for unrecoverable states (e.g., storage health failures); prefer `WARN` otherwise.
75+
- Only log client-caused exceptions when the cluster admin can act on them; otherwise rely on API responses.
76+
- Tests can assert logging via `MockLog` for complex flows.
77+
78+
## Javadoc & Comments
79+
- New packages/classes/public or abstract methods require Javadoc explaining the "why" rather than the implementation details.
80+
- Avoid documenting trivial getters/setters; focus on behavior, preconditions, or surprises.
81+
- For tests, Javadoc can describe scenario setup/expectations to aid future contributors.
82+
- Do not remove existing comments from code unless the code is also being removed or the comment has become incorrect.
83+
84+
## License Headers
85+
- Default header (outside `x-pack`): Elastic License 2.0, SSPL v1, or AGPL v3—they are already codified at the top of Java files; copy from existing sources.
86+
- Files under `x-pack` require the Elastic License 2.0-only header; IDEs configured per CONTRIBUTING.md can insert correct text automatically.
87+
88+
## Best Practices for Automation Agents
89+
- Never edit unrelated files; keep diffs tightly scoped to the task at hand.
90+
- Prefer Gradle tasks over ad-hoc scripts.
91+
- When scripting CLI sequences, leverage `gradlew` task.
92+
- Unrecognized changes: assume other agent; keep going; focus your changes. If it causes issues, stop + ask user.
93+
- Do not add "Co-Authored-By" lines to commit messages. commit messages should adhere to the 50/72 rule: use a maximum of 50 columns for the commit summary
94+
95+
## Backwards compatibility
96+
- For changes to a `Writeable` implementation (`writeTo` and constructor from `StreamInput`), add a new `public static final <UNIQUE_DESCRIPTIVE_NAME> = TransportVersion.fromName("<unique_descriptive_name>")` and use it in the new code paths. Confirm the backport branches and then generate a new version file with `./gradlew generateTransportVersion`.
97+
98+
Stay aligned with `CONTRIBUTING.md`, `BUILDING.md`, and `TESTING.asciidoc`; this AGENTS guide summarizes—but does not replace—those authoritative docs.

BUILDING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ The benefit of a dedicated project for these tests are:
216216

217217
Sometimes we want to share test fixtures to set up the code under test across multiple projects. There are basically two ways doing so.
218218

219-
Ideally we would use the build-in [java-test-fixtures](https://docs.gradle.org/current/userguide/java_testing.html#sec:java_test_fixtures) Gradle plugin.
219+
Ideally we would use the built-in [java-test-fixtures](https://docs.gradle.org/current/userguide/java_testing.html#sec:java_test_fixtures) Gradle plugin.
220220
This plugin relies on having a separate sourceSet for the test fixtures code.
221221

222222
In the Elasticsearch codebase we have test fixtures and actual tests within the same sourceSet. Therefore we introduced the `elasticsearch.internal-test-artifact` plugin to provides another build artifact of your project based on the `test` sourceSet.
@@ -232,7 +232,7 @@ dependencies {
232232
```
233233

234234
This test artifact mechanism makes use of the concept of [component capabilities](https://docs.gradle.org/current/userguide/component_capabilities.html)
235-
similar to how the Gradle build-in `java-test-fixtures` plugin works.
235+
similar to how the Gradle built-in `java-test-fixtures` plugin works.
236236

237237
`testArtifact` is a shortcut declared in the Elasticsearch build. Alternatively you can declare the dependency via
238238

REST_API_COMPATIBILITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The headers mirrors the 4 supported media types for both the `Accept` and `Conte
3939
"application/vnd.elasticsearch+cbor;compatible-with=7"
4040
```
4141

42-
The version request is found in compatible-with=7. When sent to a version 7 server will do nothing special. When sent to a version 8 server will apply compatiblity if needed. When sent to a version 9 server will fail since compatibility is only supported across 1 major version.
42+
The version request is found in compatible-with=7. When sent to a version 7 server will do nothing special. When sent to a version 8 server will apply compatibility if needed. When sent to a version 9 server will fail since compatibility is only supported across 1 major version.
4343

4444
A consumer/client may not mix "compatible-with" versions between headers. Attempts to mix and match compatible versions between `Accept` and `Content-Type` headers will result in an error. A consumer/client may mix the media type (i.e. send `yaml` and get back `json`).
4545

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/TopNBenchmark.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.compute.data.ElementType;
2424
import org.elasticsearch.compute.data.Page;
2525
import org.elasticsearch.compute.operator.Operator;
26+
import org.elasticsearch.compute.operator.topn.SharedMinCompetitive;
2627
import org.elasticsearch.compute.operator.topn.TopNEncoder;
2728
import org.elasticsearch.compute.operator.topn.TopNOperator;
2829
import org.elasticsearch.indices.breaker.CircuitBreakerMetrics;
@@ -56,6 +57,10 @@
5657
@State(Scope.Thread)
5758
@Fork(1)
5859
public class TopNBenchmark {
60+
static {
61+
LogConfigurator.configureESLogging();
62+
}
63+
5964
private static final BlockFactory blockFactory = BlockFactory.getInstance(
6065
new NoopCircuitBreaker("noop"),
6166
BigArrays.NON_RECYCLING_INSTANCE
@@ -133,6 +138,19 @@ private static Operator operator(String data, int topCount, boolean sortedInput)
133138
List.of(),
134139
ClusterSettings.createBuiltInClusterSettings()
135140
);
141+
SharedMinCompetitive.Supplier minCompetitive = new SharedMinCompetitive.Supplier(
142+
blockFactory.breaker(),
143+
IntStream.range(0, encoders.size())
144+
.mapToObj(
145+
i -> new SharedMinCompetitive.KeyConfig(
146+
elementTypes.get(i),
147+
encoders.get(i),
148+
sortOrders.get(i).asc(),
149+
sortOrders.get(i).nullsFirst()
150+
)
151+
)
152+
.toList()
153+
);
136154
return new TopNOperator(
137155
blockFactory,
138156
breakerService.getBreaker(CircuitBreaker.REQUEST),
@@ -141,7 +159,8 @@ private static Operator operator(String data, int topCount, boolean sortedInput)
141159
encoders,
142160
sortOrders,
143161
8 * 1024,
144-
sortedInput ? TopNOperator.InputOrdering.SORTED : TopNOperator.InputOrdering.NOT_SORTED
162+
sortedInput ? TopNOperator.InputOrdering.SORTED : TopNOperator.InputOrdering.NOT_SORTED,
163+
minCompetitive // This is optional, but doesn't add much overhead either way
145164
);
146165
}
147166

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/ValuesSourceReaderBenchmark.java

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.elasticsearch.compute.data.Page;
4444
import org.elasticsearch.compute.lucene.AlwaysReferencedIndexedByShardId;
4545
import org.elasticsearch.compute.lucene.IndexedByShardIdFromSingleton;
46-
import org.elasticsearch.compute.lucene.LuceneSourceOperator;
46+
import org.elasticsearch.compute.lucene.query.LuceneSourceOperator;
4747
import org.elasticsearch.compute.lucene.read.ValuesSourceReaderOperator;
4848
import org.elasticsearch.compute.lucene.read.ValuesSourceReaderOperatorStatus;
4949
import org.elasticsearch.compute.operator.DriverContext;
@@ -237,7 +237,7 @@ private static BlockLoader blockLoader(String name) {
237237
break;
238238
}
239239
ft.freeze();
240-
return new KeywordFieldMapper.KeywordFieldType(w.name, ft, syntheticSource).blockLoader(blContext());
240+
return new KeywordFieldMapper.KeywordFieldType(w.name, ft, syntheticSource).blockLoader(new BenchContext());
241241
}
242242
throw new IllegalArgumentException("can't read [" + name + "]");
243243
}
@@ -279,7 +279,7 @@ private static BlockLoader numericBlockLoader(WhereAndBaseName w, NumberFieldMap
279279
null,
280280
null,
281281
false
282-
).blockLoader(blContext());
282+
).blockLoader(new BenchContext());
283283
}
284284

285285
/**
@@ -586,52 +586,60 @@ public void teardownIndex() throws IOException {
586586
IOUtils.close(reader, directory);
587587
}
588588

589-
private static MappedFieldType.BlockLoaderContext blContext() {
590-
return new MappedFieldType.BlockLoaderContext() {
591-
@Override
592-
public String indexName() {
593-
return "benchmark";
594-
}
589+
private static class BenchContext implements MappedFieldType.BlockLoaderContext {
590+
@Override
591+
public String indexName() {
592+
return "benchmark";
593+
}
595594

596-
@Override
597-
public IndexSettings indexSettings() {
598-
throw new UnsupportedOperationException();
599-
}
595+
@Override
596+
public IndexSettings indexSettings() {
597+
throw new UnsupportedOperationException();
598+
}
600599

601-
@Override
602-
public MappedFieldType.FieldExtractPreference fieldExtractPreference() {
603-
return MappedFieldType.FieldExtractPreference.NONE;
604-
}
600+
@Override
601+
public MappedFieldType.FieldExtractPreference fieldExtractPreference() {
602+
return MappedFieldType.FieldExtractPreference.NONE;
603+
}
605604

606-
@Override
607-
public SearchLookup lookup() {
608-
throw new UnsupportedOperationException();
609-
}
605+
@Override
606+
public SearchLookup lookup() {
607+
throw new UnsupportedOperationException();
608+
}
610609

611-
@Override
612-
public Set<String> sourcePaths(String name) {
613-
return Set.of(name);
614-
}
610+
@Override
611+
public Set<String> sourcePaths(String name) {
612+
return Set.of(name);
613+
}
615614

616-
@Override
617-
public String parentField(String field) {
618-
throw new UnsupportedOperationException();
619-
}
615+
@Override
616+
public String parentField(String field) {
617+
throw new UnsupportedOperationException();
618+
}
620619

621-
@Override
622-
public FieldNamesFieldMapper.FieldNamesFieldType fieldNames() {
623-
return FieldNamesFieldMapper.FieldNamesFieldType.get(true);
624-
}
620+
@Override
621+
public FieldNamesFieldMapper.FieldNamesFieldType fieldNames() {
622+
return FieldNamesFieldMapper.FieldNamesFieldType.get(true);
623+
}
625624

626-
@Override
627-
public MappingLookup mappingLookup() {
628-
return null;
629-
}
625+
@Override
626+
public MappingLookup mappingLookup() {
627+
return null;
628+
}
630629

631-
@Override
632-
public BlockLoaderFunctionConfig blockLoaderFunctionConfig() {
633-
return null;
634-
}
635-
};
630+
@Override
631+
public BlockLoaderFunctionConfig blockLoaderFunctionConfig() {
632+
return null;
633+
}
634+
635+
@Override
636+
public ByteSizeValue ordinalsByteSize() {
637+
return DEFAULT_ORDINALS_BYTE_SIZE;
638+
}
639+
640+
@Override
641+
public ByteSizeValue scriptByteSize() {
642+
return DEFAULT_SCRIPT_BYTE_SIZE;
643+
}
636644
}
637645
}

0 commit comments

Comments
 (0)