forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into multi-project/fix/transport-version-test
- Loading branch information
Showing
4,117 changed files
with
141,776 additions
and
376,410 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
# This file is auto-generated. See .buildkite/pipelines/periodic-fwc.template.yml | ||
steps: | ||
- label: "{{matrix.FWC_VERSION}} / fwc" | ||
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false | ||
- label: $FWC_VERSION / fwc | ||
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false | ||
timeout_in_minutes: 300 | ||
agents: | ||
provider: gcp | ||
image: family/elasticsearch-ubuntu-2004 | ||
machineType: n1-standard-32 | ||
buildDirectory: /dev/shm/bk | ||
preemptible: true | ||
matrix: | ||
setup: | ||
FWC_VERSION: [] | ||
env: | ||
FWC_VERSION: "{{matrix.FWC_VERSION}}" | ||
FWC_VERSION: $FWC_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
apply plugin: 'elasticsearch.build' | ||
|
||
compileJava { | ||
tasks.named("compileJava").configure { | ||
options.release = 8 | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 123569 | ||
summary: Abort pending deletion on `IndicesService` close | ||
area: Store | ||
type: enhancement | ||
issues: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 123610 | ||
summary: Disable concurrency when `top_hits` sorts on anything but `_score` | ||
area: "Aggregations" | ||
type: bug | ||
issues: [] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
mapped_pages: | ||
- https://www.elastic.co/guide/en/elasticsearch/plugins/current/creating-classic-plugins.html | ||
--- | ||
|
||
# Creating classic plugins [creating-classic-plugins] | ||
|
||
Classic plugins provide {{es}} with mechanisms for custom authentication, authorization, scoring, and more. | ||
|
||
::::{admonition} Plugin release lifecycle | ||
:class: important | ||
|
||
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`. | ||
|
||
:::: | ||
|
||
|
||
|
||
## Classic plugin file structure [_classic_plugin_file_structure] | ||
|
||
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. | ||
|
||
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. | ||
|
||
|
||
## Example plugins [_example_plugins] | ||
|
||
The {{es}} repository contains [examples of plugins](https://github.com/elastic/elasticsearch/tree/main/plugins/examples). Some of these include: | ||
|
||
* a plugin with [custom settings](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/custom-settings) | ||
* a plugin with a [custom ingest processor](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/custom-processor) | ||
* adding [custom rest endpoints](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/rest-handler) | ||
* adding a [custom rescorer](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/rescore) | ||
* a script [implemented in Java](https://github.com/elastic/elasticsearch/tree/main/plugins/examples/script-expert-scoring) | ||
|
||
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. | ||
|
||
|
||
## Testing your plugin [_testing_your_plugin] | ||
|
||
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. | ||
|
||
|
||
## Java Security permissions [plugin-authors-jsm] | ||
|
||
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! | ||
|
||
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. | ||
|
||
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: | ||
|
||
```java | ||
// ES permission you should check before doPrivileged() blocks | ||
import org.elasticsearch.SpecialPermission; | ||
|
||
SecurityManager sm = System.getSecurityManager(); | ||
if (sm != null) { | ||
// unprivileged code such as scripts do not have SpecialPermission | ||
sm.checkPermission(new SpecialPermission()); | ||
} | ||
AccessController.doPrivileged( | ||
// sensitive operation | ||
); | ||
``` | ||
|
||
Check [Secure Coding Guidelines for Java SE](https://www.oracle.com/technetwork/java/seccodeguide-139067.md) for more information. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
mapped_pages: | ||
- https://www.elastic.co/guide/en/elasticsearch/plugins/current/creating-stable-plugins.html | ||
--- | ||
|
||
# Creating text analysis plugins with the stable plugin API [creating-stable-plugins] | ||
|
||
Text analysis plugins provide {{es}} with custom [Lucene analyzers, token filters, character filters, and tokenizers](docs-content://manage-data/data-store/text-analysis.md). | ||
|
||
|
||
## The stable plugin API [_the_stable_plugin_api] | ||
|
||
Text analysis plugins can be developed against the stable plugin API. This API consists of the following dependencies: | ||
|
||
* `plugin-api` - an API used by plugin developers to implement custom {{es}} plugins. | ||
* `plugin-analysis-api` - an API used by plugin developers to implement analysis plugins and integrate them into {{es}}. | ||
* `lucene-analysis-common` - a dependency of `plugin-analysis-api` that contains core Lucene analysis interfaces like `Tokenizer`, `Analyzer`, and `TokenStream`. | ||
|
||
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. | ||
|
||
A text analysis plugin can implement four factory classes that are provided by the analysis plugin API. | ||
|
||
* `AnalyzerFactory` to create a Lucene analyzer | ||
* `CharFilterFactory` to create a character character filter | ||
* `TokenFilterFactory` to create a Lucene token filter | ||
* `TokenizerFactory` to create a Lucene tokenizer | ||
|
||
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. | ||
|
||
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. | ||
|
||
|
||
## Stable plugin file structure [_stable_plugin_file_structure] | ||
|
||
Stable plugins are ZIP files composed of JAR files and two metadata files: | ||
|
||
* `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). | ||
* `named_components.json` - a JSON file mapping interfaces to key-value pairs of component names and implementation classes. | ||
|
||
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. | ||
|
||
|
||
## Development process [_development_process] | ||
|
||
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. | ||
|
||
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. | ||
|
||
|
||
### Prerequisites [_prerequisites] | ||
|
||
Plugins are written in Java, so you need to install a Java Development Kit (JDK). Install Gradle if you want to use Gradle. | ||
|
||
|
||
### Step by step [_step_by_step] | ||
|
||
1. Create a directory for your project. | ||
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. | ||
3. Edit the `build.gradle` build script: | ||
|
||
* 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/). | ||
* 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. | ||
* Add module information. | ||
* Ensure you have declared the following compile-time dependencies. These dependencies are compile-time only because {{es}} will provide these libraries at runtime. | ||
|
||
* `org.elasticsearch.plugin:elasticsearch-plugin-api` | ||
* `org.elasticsearch.plugin:elasticsearch-plugin-analysis-api` | ||
* `org.apache.lucene:lucene-analysis-common` | ||
|
||
* For unit testing, ensure these dependencies have also been added to the `build.gradle` script as `testImplementation` dependencies. | ||
|
||
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. | ||
5. You should now be able to assemble a plugin ZIP file by running: | ||
|
||
```sh | ||
gradle bundlePlugin | ||
``` | ||
|
||
The resulting plugin ZIP file is written to the `build/distributions` directory. | ||
|
||
|
||
|
||
### YAML REST tests [_yaml_rest_tests] | ||
|
||
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: | ||
|
||
* A test suite class, defined under `src/yamlRestTest/java`. This class should extend `ESClientYamlSuiteTestCase`. | ||
* The YAML tests themselves should be defined under `src/yamlRestTest/resources/test/`. | ||
|
||
|
||
|
Oops, something went wrong.