Elasticsearch & Google Cloud

As we have our Firebase on the google cloud platform, I thought setting up and integrating Elasticsearch on google’s cloud will be a breeze and I would be up and running integrations in no time (turns out I was wrong and it took longer than I thought).

So I signed up for their free trial - https://cloud.google.com/free/ and started my setup of an Elasticsearch deployment using their cloud launcher - https://console.cloud.google.com/launcher/details/click-to-deploy-images/elasticsearch. (Please make sure you familiarize yourself with the Google Compute Engine Pricing as you’ll incur charges once the free tier is used up).

Google Cloud Platform

As the Elasticsearch platform runs on the google cloud compute engine, I would suggest getting familiarized with the google cloud compute and the cloud platform in general - https://cloud.google.com/docs/overview/.

Setup Elasticsearch on Google Cloud Compute

The basic setup for Elasticsearch was pretty easy. Using the click to deploy link, click on “Launch on Compute Engine”. You might need to select (or create) the project you want to set this up on. On the next screen, you would see configuration options for your Elasticsearch VMs. You can customize this as per your requirements. I chose to reduce the machine type configuration to lower the costs. (Please refer to their compute pricing link above)

Elasticsearch - Google Cloud Platform

It could take a few minutes to set this up.

Connecting from development machine using gcloud sdk

To connect to our newly created Elasticsearch VMs, we need to use the gcloud sdk. The gcloud sdk allows us to tunnel into Google’s cloud platform.

Download and install the gcloud sdk. Once installed, run the following one-time setup command for your machine

gcloud init

The init command will prompt you to login and select a default cloud project.

You can then run the ssh command to connect to your VM (use your project name and change the zone and VM name as needed).

gcloud compute ssh --ssh-flag=”-L 9200:localhost:9200” --project=<project name> --zone=us-central1-f elasticsearch-1-1-vm

We’re connecting to port 9200 as that’s the default http port for Elasticsearch.

You can test to make sure that Elasticsearch is up and running by using the curl command or test it in the browser.

curl http://localhost:9200

You should get an output that looks like this -

{

"name" : "elasticsearch-1-1-vm",

"cluster_name" : "elasticsearch-cluster",

"cluster_uuid" : "...",

"version" : {

"number" : "2.4.4",

"build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017",

"build_timestamp" : "2017-01-03T11:33:16Z",

"build_snapshot" : false,

"lucene_version" : "5.5.2"

},

"tagline" : "You Know, for Search"

}

Sense Chrome Extension

In order to test and execute search queries, we can use the Sense (Beta) Chrome extension https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig?hl=en

You can now query http://localhost:9200. Use the default query to ensure that you get results -