Hold Elasticsearch back on 2.4 for Chewy on macOS

So, Elasticsearch 5.0.0 is out.

I’m using Chewy, a Ruby DSL gem that’s quite good. It’s not quite there yet with the deprecated Query APIs, (see Release Notes), so to keep using it you need to hold back to the Elasticsearch 2.4 series which is the last stable release. (Question about this, answered in the issue tracker.)

Smoky mountain top
Every upgrade is a damn climb. Yesterday was a good day. It was until 15:00 before I came upon package management issues.

Here are a couple of Homebrew invocations to stay on 2.4, with full data-loss, since the index version has been upgraded.

curl localhost:9200

The output for 5.0.0 is:

{
  "name" : "61mKC-n",
  "cluster_name" : "elasticsearch_olle",
  "cluster_uuid" : "EtOE3oHxQRSur5_qhRr-TQ",
  "version" : {
    "number" : "5.0.0",
    "build_hash" : "253032b",
    "build_date" : "2016-10-26T04:37:51.531Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.0"
  },
  "tagline" : "You Know, for Search"
}

This is the version 5.0.0 that we can’t use with Chewy.

brew services status elasticsearch

If you don’t have one of those services running, you can skip a few steps.

brew services stop elasticsearch
brew unlink elasticsearch 

Now, with a clean slate, we can ask Homebrew to install a specific version (actually, a release series, “2.4”):

brew tap homebrew/versions
brew install elasticsearch24 
brew services start elasticsearch24

If you now run curl localhost:9200 you’ll may perhaps not see JSON ouput: if your index has been running on the 5.0.0, its lucene_index version would’ve been bumped, so that 2.4 can no longer read it.

The data files used by your Elasticsearch resides in /usr/local/var/elasticsearch. My node was called elasticsearch_olle and I decided to move all of its data out to a non-important folder on my harddrive:

mv /usr/local/var/elasticsearch/elasticsearch_olle ~/slask

After that, I could

brew services restart elasticsearch24

and then curl localhost:9200, to see the following 2.4 output:

{
  "name" : "Miss America",
  "cluster_name" : "elasticsearch_olle",
  "cluster_uuid" : "ym_Ovns4RHWqh-ZRcHWxcw",
  "version" : {
    "number" : "2.4.1",
    "build_hash" : "c67dc32e24162035d18d6fe1e952c4cbcbe79d16",
    "build_timestamp" : "2016-09-27T18:57:55Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

“Winning.”

Photo credit: Kamil Szybalski

Leave a Reply

Your email address will not be published. Required fields are marked *