How to Check Your Elasticsearch Version from the Command Line

Introduction

If you’re storing data in Elasticsearch you’re likely to encounter situations where you need to know what version of the product you’re running. There are many reasons why you may need to know the version. You may need to check to see if an upgrade is needed or you may need to ensure compatibility with other components of the Elastic stack. Regardless of your reason for requiring the version, Elasticsearch makes it easy to determine the version. In this tutorial you’ll learn two simple ways to check your Elasticsearch version from the command line.

Prerequisites

Before you attempt to check your version of Elasticsearch a few key prerequisites need to be in place. The system requirements are minimal:

  • Ensure that Elasticsearch is installed and running.

To check if Elasticsearch is running execute the following command in the terminal:

curl http://localhost:9200/_cluster/health?pretty

You should receive output containing information about your instance of Elasticsearch. If you know that Elasticsearch is installed but you don’t receive the expected output, you may need to restart Elasticsearch on your machine.

Once you’ve confirmed this, all you need is a basic familiarity with command line tools and curl commands. If you haven’t had much experience with curl functionality the underlying concept is simple: curl allows you to use HTTP requests to communicate with a server. In this tutorial we’ll use curl to communicate with Elasticsearch.

Check Version Options

OPTION 1: Check Version using Curl from Command Line

There are two simple ways that you can use command-line operations to find out what version of Elasticsearch you’re running. The first method for checking your Elasticsearch version makes use of the curl command. With Elasticsearch running, execute the curl command shown below in your terminal to get information about your version of Elasticsearch:

curl -XGET 'http://localhost:9200'
  • In this example, Elasticsearch is running locally on the default port so our HTTP request will be to http://localhost:9200. If Elasticsearch was running on a different server your HTTP request would take the form http://YOURDOMAIN.com:9200.

The following results contain some information about Elasticsearch that includes the version number. In this example, the results show that our version of Elasticsearch is 6.6.1:

{
"name" : "pn0zUv9",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "GmzCPer3SP-AZ_Nd_zGQ4g",
"version" : {
"number" : "6.6.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "1fd8f69",
"build_date" : "2019-02-13T17:10:04.160291Z",
"build_snapshot" : false,
"lucene_version" : "7.6.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

Note: If the version number shown in your output is different from the version you’ve installed, you may have more than one installation of Elasticsearch on your machine.

OPTION 2: Check Version with elasticsearch –version

In addition to using the previous command it’s also possible to find out the version number just by starting Elasticsearch. When Elasticsearch starts up it outputs the version number; however, it also outputs a lot of other information so it can be difficult to sort through the output to find it. You can cut through the clutter and get the version information directly by using the version flag when starting Elasticsearch. The following example shows how to run the command on MacOS. The specific command syntax will vary depending on your operating system:

bin/elasticsearch --version

The output, which includes information on our version, is shown below:

...
Version: 6.6.1, Build: default/tar/1fd8f69/2019-02-13T17:10:04.160291Z, JVM: 11.0.2

Again, you can easily see that the installed version of Elasticsearch is 6.6.1.

Conclusion

When you’re working with Elasticsearch there will be times when you need to check your version of the product– it may be to check for compatibility issues with other components of the Elastic stack, or it might be to see if an upgrade is needed. Fortunately, it’s simple to check your Elasticsearch version using the two methods described above. With these step-by-step instructions all you need as a basic familiarity with curl functionality and command-line tools to get the information you need. If you need help managing your database for your application please don’t hesitate to reach out to one of the experts at Object Rocket.

Pilot the ObjectRocket Platform Free!

Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.

Get Started

Keep in the know!

Subscribe to our emails and we’ll let you know what’s going on at ObjectRocket. We hate spam and make it easy to unsubscribe.