"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.23/CONTRIBUTING.md" (29 Dec 2021, 19781 Bytes) of package /linux/www/elasticsearch-6.8.23-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


Contributing to elasticsearch

Elasticsearch is an open source project and we love to receive contributions from our community — you! There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code which can be incorporated into Elasticsearch itself.

Bug reports

If you think you have found a bug in Elasticsearch, first make sure that you are testing against the latest version of Elasticsearch - your issue may already have been fixed. If not, search our issues list on GitHub in case a similar issue has already been opened.

It is very helpful if you can prepare a reproduction of the bug. In other words, provide a small test case which we can run to confirm your bug. It makes it easier to find the problem and to fix it. Test cases should be provided as curl commands which we can copy and paste into a terminal to run it locally, for example:

# delete the index
curl -XDELETE localhost:9200/test

# insert a document
curl -XPUT localhost:9200/test/test/1 -d '{
 "title": "test document"
}'

# this should return XXXX but instead returns YYY
curl ....

Provide as much information as you can. You may think that the problem lies with your query, when actually it depends on how your data is indexed. The easier it is for us to recreate your problem, the faster it is likely to be fixed.

Feature requests

If you find yourself wishing for a feature that doesn't exist in Elasticsearch, you are probably not alone. There are bound to be others out there with similar needs. Many of the features that Elasticsearch has today have been added because our users saw the need. Open an issue on our issues list on GitHub which describes the feature you would like to see, why you need it, and how it should work.

Contributing code and documentation changes

If you have a bugfix or new feature that you would like to contribute to Elasticsearch, please find or open an issue about it first. Talk about what you would like to do. It may be that somebody is already working on it, or that there are particular issues that you should know about before implementing the change.

We enjoy working with contributors to get their code accepted. There are many approaches to fixing a problem and it is important to find the best approach before writing too much code.

Note that it is unlikely the project will merge refactors for the sake of refactoring. These types of pull requests have a high cost to maintainers in reviewing and testing with little to no tangible benefit. This especially includes changes generated by tools. For example, converting all generic interface instances to use the diamond operator.

The process for contributing to any of the Elastic repositories is similar. Details for individual projects can be found below.

Fork and clone the repository

You will need to fork the main Elasticsearch code or documentation repository and clone it to your local machine. See github help page for help.

Further instructions for specific projects are given below.

Submitting your changes

Once your changes and tests are ready to submit for review:

  1. Test your changes

    Run the test suite to make sure that nothing is broken. See the TESTING file for help running tests.

  2. Sign the Contributor License Agreement

    Please make sure you have signed our Contributor License Agreement. We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once.

  3. Rebase your changes

    Update your local repository with the most recent code from the main Elasticsearch repository, and rebase your branch on top of the latest master branch. We prefer your initial changes to be squashed into a single commit. Later, if we ask you to make changes, add them as separate commits. This makes them easier to review. As a final step before merging we will either ask you to squash all commits yourself or we'll do it for you.

  4. Submit a pull request

    Push your local changes to your forked copy of the repository and submit a pull request. In the pull request, choose a title which sums up the changes that you have made, and in the body provide more details about what your changes do. Also mention the number of the issue where discussion has taken place, eg "Closes #123".

Then sit back and wait. There will probably be discussion about the pull request and, if any changes are needed, we would love to work with you to get your pull request merged into Elasticsearch.

Please adhere to the general guideline that you should never force push to a publicly shared branch. Once you have opened your pull request, you should consider your branch publicly shared. Instead of force pushing you can just add incremental commits; this is generally easier on your reviewers. If you need to pick up changes from master, you can merge master into your branch. A reviewer might ask you to rebase a long-running pull request in which case force pushing is okay for that request. Note that squashing at the end of the review process should also not be done, that can be done when the pull request is integrated via GitHub.

Contributing to the Elasticsearch codebase

Repository: https://github.com/elastic/elasticsearch

JDK 12 is required to build Elasticsearch. You must have a JDK 12 installation with the environment variable JAVA_HOME referencing the path to Java home for your JDK 12 installation. By default, tests use the same runtime as JAVA_HOME. However, since Elasticsearch supports JDK 8, the build supports compiling with JDK 12 and testing on a JDK 8 runtime; to do this, set RUNTIME_JAVA_HOME pointing to the Java home of a JDK 8 installation. Note that this mechanism can be used to test against other JDKs as well, this is not only limited to JDK 8.

Note: It is also required to have JAVA8_HOME, JAVA9_HOME, JAVA10_HOME and JAVA11_HOME available so that the tests can pass.

Warning: do not use sdkman for Java installations which do not have proper jrunscript for jdk distributions.

Elasticsearch uses the Gradle wrapper for its build. You can execute Gradle using the wrapper via the gradlew script in the root of the repository.

We support development in IntelliJ versions IntelliJ 2019.2 and onwards. We would like to support Eclipse, but few of us use it and has fallen into disrepair.

Importing the project into IntelliJ IDEA

Elasticsearch builds using Java 12. Before importing into IntelliJ you will need to define an appropriate SDK. The convention is that this SDK should be named "12" so that the project import will detect it automatically. For more details on defining an SDK in IntelliJ please refer to their documentation.

You can import the Elasticsearch project into IntelliJ IDEA via:

To run an instance of elasticsearch from the source code run ./gradlew run

Please follow these formatting guidelines:

License Headers

We require license headers on all Java files. With the exception of the top-level x-pack directory, all contributed code should have the following license header unless instructed otherwise:

/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

The top-level x-pack directory contains code covered by the Elastic license. Community contributions to this code are welcome, and should have the following license header unless instructed otherwise:

/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

It is important that the only code covered by the Elastic licence is contained within the top-level x-pack directory. The build will fail its pre-commit checks if contributed code does not have the appropriate license headers.

NOTE: If you have imported the project into IntelliJ IDEA the project will be automatically configured to add the correct license header to new source files based on the source location.

Creating A Distribution

Run all build commands from within the root directory:

cd elasticsearch/

To build a tar distribution, run this command:

./gradlew -p distribution/archives/tar assemble --parallel

You will find the distribution under: ./distribution/archives/tar/build/distributions/

To create all build artifacts (e.g., plugins and Javadocs) as well as distributions in all formats, run this command:

./gradlew assemble --parallel

The package distributions (Debian and RPM) can be found under: ./distribution/packages/(deb|rpm)/build/distributions/

The archive distributions (tar and zip) can be found under: ./distribution/archives/(tar|zip)/build/distributions/

Running The Full Test Suite

Before submitting your changes, run the test suite to make sure that nothing is broken, with:

./gradlew check

If your changes affect only the documentation, run:

./gradlew -p docs check

For more information about testing code examples in the documentation, see https://github.com/elastic/elasticsearch/blob/master/docs/README.asciidoc

Project layout

This repository is split into many top level directories. The most important ones are:

docs

Documentation for the project.

distribution

Builds our tar and zip archives and our rpm and deb packages.

libs

Libraries used to build other parts of the project. These are meant to be internal rather than general purpose. We have no plans to semver their APIs or accept feature requests for them. We publish them to maven central because they are dependencies of our plugin test framework, high level rest client, and jdbc driver but they really aren't general purpose enough to belong in maven central. We're still working out what to do here.

modules

Features that are shipped with Elasticsearch by default but are not built in to the server. We typically separate features from the server because they require permissions that we don't believe all of Elasticsearch should have or because they depend on libraries that we don't believe all of Elasticsearch should depend on.

For example, reindex requires the connect permission so it can perform reindex-from-remote but we don't believe that the all of Elasticsearch should have the "connect". For another example, Painless is implemented using antlr4 and asm and we don't believe that all of Elasticsearch should have access to them.

plugins

Officially supported plugins to Elasticsearch. We decide that a feature should be a plugin rather than shipped as a module because we feel that it is only important to a subset of users, especially if it requires extra dependencies.

The canonical example of this is the ICU analysis plugin. It is important for folks who want the fairly language neutral ICU analyzer but the library to implement the analyzer is 11MB so we don't ship it with Elasticsearch by default.

Another example is the discovery-gce plugin. It is vital to folks running in GCP but useless otherwise and it depends on a dozen extra jars.

qa

Honestly this is kind of in flux and we're not 100% sure where we'll end up. Right now the directory contains

server

The server component of Elasticsearch that contains all of the modules and plugins. Right now things like the high level rest client depend on the server but we'd like to fix that in the future.

test

Our test framework and test fixtures. We use the test framework for testing the server, the plugins, and modules, and pretty much everything else. We publish the test framework so folks who develop Elasticsearch plugins can use it to test the plugins. The test fixtures are external processes that we start before running specific tests that rely on them.

For example, we have an hdfs test that uses mini-hdfs to test our repository-hdfs plugin.

x-pack

Commercially licensed code that integrates with the rest of Elasticsearch. The docs subdirectory functions just like the top level docs subdirectory and the qa subdirectory functions just like the top level qa subdirectory. The plugin subdirectory contains the x-pack module which runs inside the Elasticsearch process. The transport-client subdirectory contains extensions to Elasticsearch's standard transport client to work properly with x-pack.

Gradle Build

We use Gradle to build Elasticsearch because it is flexible enough to not only build and package Elasticsearch, but also orchestrate all of the ways that we have to test Elasticsearch.

Configurations

Gradle organizes dependencies and build artifacts into "configurations" and allows you to use these configurations arbitrarily. Here are some of the most common configurations in our build and how we use them:

`compile`
Code that is on the classpath at both compile and runtime.
`runtime`
Code that is not on the classpath at compile time but is on the classpath at runtime. We mostly use this configuration to make sure that we do not accidentally compile against dependencies of our dependencies also known as "transitive" dependencies".
`compileOnly`
Code that is on the classpath at compile time but that should not be shipped with the project because it is "provided" by the runtime somehow. Elasticsearch plugins use this configuration to include dependencies that are bundled with Elasticsearch's server.
`bundle`
Only available in projects with the shadow plugin, dependencies with this configuration are bundled into the jar produced by the build. Since IDEs do not understand this configuration we rig them to treat dependencies in this configuration as `compile` dependencies.
`testCompile`
Code that is on the classpath for compiling tests that are part of this project but not production code. The canonical example of this is `junit`.

Contributing as part of a class

In general Elasticsearch is happy to accept contributions that were created as part of a class but strongly advise against making the contribution as part of the class. So if you have code you wrote for a class feel free to submit it.

Please, please, please do not assign contributing to Elasticsearch as part of a class. If you really want to assign writing code for Elasticsearch as an assignment then the code contributions should be made to your private clone and opening PRs against the primary Elasticsearch clone must be optional, fully voluntary, not for a grade, and without any deadlines.

Because:

Finally, we require that you run ./gradlew check before submitting a non-documentation contribution. This is mentioned above, but it is worth repeating in this section because it has come up in this context.