Skip to content

Commit 476c3f3

Browse files
authored
Merge branch 'main' into tmp/fake
2 parents 603a2b2 + 9052226 commit 476c3f3

File tree

4,109 files changed

+141751
-376394
lines changed

Some content is hidden

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

4,109 files changed

+141751
-376394
lines changed

.buildkite/pipelines/periodic-fwc.template.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ steps:
77
image: family/elasticsearch-ubuntu-2004
88
machineType: n1-standard-32
99
buildDirectory: /dev/shm/bk
10-
preemptible: true
1110
matrix:
1211
setup:
1312
FWC_VERSION: $FWC_LIST
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# This file is auto-generated. See .buildkite/pipelines/periodic-fwc.template.yml
22
steps:
3-
- label: "{{matrix.FWC_VERSION}} / fwc"
4-
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
3+
- label: $FWC_VERSION / fwc
4+
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
55
timeout_in_minutes: 300
66
agents:
77
provider: gcp
88
image: family/elasticsearch-ubuntu-2004
99
machineType: n1-standard-32
1010
buildDirectory: /dev/shm/bk
11-
preemptible: true
1211
matrix:
1312
setup:
1413
FWC_VERSION: []
1514
env:
16-
FWC_VERSION: "{{matrix.FWC_VERSION}}"
15+
FWC_VERSION: $FWC_VERSION

build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ develocity {
133133
}
134134
} else {
135135
tag 'LOCAL'
136+
if (providers.systemProperty('idea.active').present) {
137+
tag 'IDEA'
138+
}
136139
}
137140
}
138141
}

build-tools-internal/src/main/groovy/elasticsearch.ide.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
179179

180180
// this path is produced by the extractLibs task above
181181
String testLibraryPath = TestUtil.getTestLibraryPath("${elasticsearchProject.left()}/libs/native/libraries/build/platform")
182-
182+
def enableIdeaCC = providers.gradleProperty("org.elasticsearch.idea-configuration-cache").getOrElse("true").toBoolean()
183183
idea {
184184
project {
185185
vcs = 'Git'
@@ -209,6 +209,11 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
209209
}
210210
}
211211
runConfigurations {
212+
defaults(org.jetbrains.gradle.ext.Gradle) {
213+
scriptParameters = enableIdeaCC ? [
214+
'--configuration-cache'
215+
].join(' ') : ''
216+
}
212217
defaults(JUnit) {
213218
vmParameters = [
214219
'-ea',

docs/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ ext.docsFileTree = fileTree(projectDir) {
3737
}
3838

3939
tasks.named("yamlRestTest") {
40+
enabled = false
4041
if (buildParams.isSnapshotBuild() == false) {
4142
// LOOKUP is not available in snapshots
4243
systemProperty 'tests.rest.blacklist', [
@@ -47,6 +48,7 @@ tasks.named("yamlRestTest") {
4748

4849
/* List of files that have snippets that will not work until platinum tests can occur ... */
4950
tasks.named("buildRestTests").configure {
51+
enabled = false
5052
getExpectedUnconvertedCandidates().addAll(
5153
'reference/ml/anomaly-detection/ml-configuring-transform.asciidoc',
5254
'reference/ml/anomaly-detection/apis/delete-calendar-event.asciidoc',

docs/changelog/123569.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123569
2+
summary: Abort pending deletion on `IndicesService` close
3+
area: Store
4+
type: enhancement
5+
issues: []

docs/changelog/123610.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123610
2+
summary: Disable concurrency when `top_hits` sorts on anything but `_score`
3+
area: "Aggregations"
4+
type: bug
5+
issues: []

docs/docset.yml

Lines changed: 506 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/elasticsearch/plugins/current/creating-classic-plugins.html
4+
---
5+
6+
# Creating classic plugins [creating-classic-plugins]
7+
8+
Classic plugins provide {{es}} with mechanisms for custom authentication, authorization, scoring, and more.
9+
10+
::::{admonition} Plugin release lifecycle
11+
:class: important
12+
13+
Classic plugins require you to build a new version for each new {{es}} release. This version is checked when the plugin is installed and when it is loaded. {{es}} will refuse to start in the presence of plugins with the incorrect `elasticsearch.version`.
14+
15+
::::
16+
17+
18+
19+
## Classic plugin file structure [_classic_plugin_file_structure]
20+
21+
Classic plugins are ZIP files composed of JAR files and [a metadata file called `plugin-descriptor.properties`](/extend/plugin-descriptor-file-classic.md), a Java properties file that describes the plugin.
22+
23+
Note that only JAR files at the root of the plugin are added to the classpath for the plugin. If you need other resources, package them into a resources JAR.
24+
25+
26+
## Example plugins [_example_plugins]
27+
28+
The {{es}} repository contains [examples of plugins](https://github.com/elastic/elasticsearch/tree/main/plugins/examples). Some of these include:
29+
30+
* a plugin with [custom settings](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/custom-settings)
31+
* a plugin with a [custom ingest processor](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/custom-processor)
32+
* adding [custom rest endpoints](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/rest-handler)
33+
* adding a [custom rescorer](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/rescore)
34+
* a script [implemented in Java](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/script-expert-scoring)
35+
36+
These examples provide the bare bones needed to get started. For more information about how to write a plugin, we recommend looking at the [source code of existing plugins](https://github.com/elastic/elasticsearch/tree/main/plugins/) for inspiration.
37+
38+
39+
## Testing your plugin [_testing_your_plugin]
40+
41+
Use `bin/elasticsearch-plugin install file:///path/to/your/plugin` to install your plugin for testing. The Java plugin is auto-loaded only if it’s in the `plugins/` directory.
42+
43+
44+
## Java Security permissions [plugin-authors-jsm]
45+
46+
Some plugins may need additional security permissions. A plugin can include the optional `plugin-security.policy` file containing `grant` statements for additional permissions. Any additional permissions will be displayed to the user with a large warning, and they will have to confirm them when installing the plugin interactively. So if possible, it is best to avoid requesting any spurious permissions!
47+
48+
If you are using the {{es}} Gradle build system, place this file in `src/main/plugin-metadata` and it will be applied during unit tests as well.
49+
50+
The Java security model is stack-based, and additional permissions are granted to the jars in your plugin, so you have to write proper security code around operations requiring elevated privileges. You might add a check to prevent unprivileged code (such as scripts) from gaining escalated permissions. For example:
51+
52+
```java
53+
// ES permission you should check before doPrivileged() blocks
54+
import org.elasticsearch.SpecialPermission;
55+
56+
SecurityManager sm = System.getSecurityManager();
57+
if (sm != null) {
58+
// unprivileged code such as scripts do not have SpecialPermission
59+
sm.checkPermission(new SpecialPermission());
60+
}
61+
AccessController.doPrivileged(
62+
// sensitive operation
63+
);
64+
```
65+
66+
Check [Secure Coding Guidelines for Java SE](https://www.oracle.com/technetwork/java/seccodeguide-139067.md) for more information.
67+
68+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/elasticsearch/plugins/current/creating-stable-plugins.html
4+
---
5+
6+
# Creating text analysis plugins with the stable plugin API [creating-stable-plugins]
7+
8+
Text analysis plugins provide {{es}} with custom [Lucene analyzers, token filters, character filters, and tokenizers](docs-content://manage-data/data-store/text-analysis.md).
9+
10+
11+
## The stable plugin API [_the_stable_plugin_api]
12+
13+
Text analysis plugins can be developed against the stable plugin API. This API consists of the following dependencies:
14+
15+
* `plugin-api` - an API used by plugin developers to implement custom {{es}} plugins.
16+
* `plugin-analysis-api` - an API used by plugin developers to implement analysis plugins and integrate them into {{es}}.
17+
* `lucene-analysis-common` - a dependency of `plugin-analysis-api` that contains core Lucene analysis interfaces like `Tokenizer`, `Analyzer`, and `TokenStream`.
18+
19+
For new versions of {{es}} within the same major version, plugins built against this API does not need to be recompiled. Future versions of the API will be backwards compatible and plugins are binary compatible with future versions of {{es}}. In other words, once you have a working artifact, you can re-use it when you upgrade {{es}} to a new bugfix or minor version.
20+
21+
A text analysis plugin can implement four factory classes that are provided by the analysis plugin API.
22+
23+
* `AnalyzerFactory` to create a Lucene analyzer
24+
* `CharFilterFactory` to create a character character filter
25+
* `TokenFilterFactory` to create a Lucene token filter
26+
* `TokenizerFactory` to create a Lucene tokenizer
27+
28+
The key to implementing a stable plugin is the `@NamedComponent` annotation. Many of {{es}}'s components have names that are used in configurations. For example, the keyword analyzer is referenced in configuration with the name `"keyword"`. Once your custom plugin is installed in your cluster, your named components may be referenced by name in these configurations as well.
29+
30+
You can also create text analysis plugins as a [classic plugin](/extend/creating-classic-plugins.md). However, classic plugins are pinned to a specific version of {{es}}. You need to recompile them when upgrading {{es}}. Because classic plugins are built against internal APIs that can change, upgrading to a new version may require code changes.
31+
32+
33+
## Stable plugin file structure [_stable_plugin_file_structure]
34+
35+
Stable plugins are ZIP files composed of JAR files and two metadata files:
36+
37+
* `stable-plugin-descriptor.properties` - a Java properties file that describes the plugin. Refer to [The plugin descriptor file for stable plugins](/extend/plugin-descriptor-file-stable.md).
38+
* `named_components.json` - a JSON file mapping interfaces to key-value pairs of component names and implementation classes.
39+
40+
Note that only JAR files at the root of the plugin are added to the classpath for the plugin. If you need other resources, package them into a resources JAR.
41+
42+
43+
## Development process [_development_process]
44+
45+
Elastic provides a Gradle plugin, `elasticsearch.stable-esplugin`, that makes it easier to develop and package stable plugins. The steps in this section assume you use this plugin. However, you don’t need Gradle to create plugins.
46+
47+
The {{es}} Github repository contains [an example analysis plugin](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/stable-analysis). The example `build.gradle` build script provides a good starting point for developing your own plugin.
48+
49+
50+
### Prerequisites [_prerequisites]
51+
52+
Plugins are written in Java, so you need to install a Java Development Kit (JDK). Install Gradle if you want to use Gradle.
53+
54+
55+
### Step by step [_step_by_step]
56+
57+
1. Create a directory for your project.
58+
2. Copy the example `build.gradle` build script to your project directory. Note that this build script uses the `elasticsearch.stable-esplugin` gradle plugin to build your plugin.
59+
3. Edit the `build.gradle` build script:
60+
61+
* Add a definition for the `pluginApiVersion` and matching `luceneVersion` variables to the top of the file. You can find these versions in the `build-tools-internal/version.properties` file in the [Elasticsearch Github repository](https://github.com/elastic/elasticsearch/).
62+
* Edit the `name` and `description` in the `esplugin` section of the build script. This will create the plugin descriptor file. If you’re not using the `elasticsearch.stable-esplugin` gradle plugin, refer to [The plugin descriptor file for stable plugins](/extend/plugin-descriptor-file-stable.md) to create the file manually.
63+
* Add module information.
64+
* Ensure you have declared the following compile-time dependencies. These dependencies are compile-time only because {{es}} will provide these libraries at runtime.
65+
66+
* `org.elasticsearch.plugin:elasticsearch-plugin-api`
67+
* `org.elasticsearch.plugin:elasticsearch-plugin-analysis-api`
68+
* `org.apache.lucene:lucene-analysis-common`
69+
70+
* For unit testing, ensure these dependencies have also been added to the `build.gradle` script as `testImplementation` dependencies.
71+
72+
4. Implement an interface from the analysis plugin API, annotating it with `NamedComponent`. Refer to [Example text analysis plugin](/extend/example-text-analysis-plugin.md) for an example.
73+
5. You should now be able to assemble a plugin ZIP file by running:
74+
75+
```sh
76+
gradle bundlePlugin
77+
```
78+
79+
The resulting plugin ZIP file is written to the `build/distributions` directory.
80+
81+
82+
83+
### YAML REST tests [_yaml_rest_tests]
84+
85+
The Gradle `elasticsearch.yaml-rest-test` plugin enables testing of your plugin using the [{{es}} yamlRestTest framework](https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc). These tests use a YAML-formatted domain language to issue REST requests against an internal {{es}} cluster that has your plugin installed, and to check the results of those requests. The structure of a YAML REST test directory is as follows:
86+
87+
* A test suite class, defined under `src/yamlRestTest/java`. This class should extend `ESClientYamlSuiteTestCase`.
88+
* The YAML tests themselves should be defined under `src/yamlRestTest/resources/test/`.
89+
90+
91+

0 commit comments

Comments
 (0)