When using Elasticsearch, checking its version is a common need that helps identify available features, troubleshoot issues, or address compatibility concerns. Here are some methods to determine the version of Elasticsearch you are using:
Method 1: Using REST API
Elasticsearch offers a straightforward REST API for retrieving detailed information about the cluster, nodes, and version. You can use the curl command or any HTTP client tool to send requests. This is the simplest approach.
For example, if you use curl, you can check the version with the following command:
bashcurl -X GET "localhost:9200"
After executing this command, you will receive a JSON response containing various details about the Elasticsearch cluster, including the version number. The response example is as follows:
json{ "name" : "node-1", "cluster_name" : "elasticsearch-cluster", "cluster_uuid" : "aHR0cHM6Ly9lbGFzdGljc2VhcmNo", "version" : { "number" : "7.10.0", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "f0f09f1", "build_date" : "2020-11-09T21:30:33.964949Z", "build_snapshot" : false, "lucene_version" : "8.7.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
In this JSON response, the version.number field indicates the Elasticsearch version. Here, it is 7.10.0.
Method 2: Using Kibana
If you use Kibana as your visualization tool for Elasticsearch, you can easily locate the version information. Once logged into Kibana, you'll typically find the Elasticsearch server version in the bottom navigation bar or on the homepage.
Method 3: Checking Elasticsearch Log Files
Upon starting Elasticsearch, it logs version information to the log files. These logs are usually located in the logs directory under the Elasticsearch installation path. Open the most recent log file to find the version information recorded during startup.
Method 4: Checking the Installation Package or Directory
If you have access to the Elasticsearch server, you can directly examine the installation directory or package name, which typically contain the version number. For instance, if installed via a package, the package name might resemble elasticsearch-7.10.0.deb.
Using any of the above methods, you can effectively verify and confirm the version of Elasticsearch you are running. This is crucial for maintenance, upgrades, or leveraging specific features.