In order to continue providing reliable GFD (great freakin’ data) to our clients, the product development team here at gap intelligence recently upgraded our core application from Rails 4.2 to 5.0,  a very necessary and complex update that took over 8 weeks to complete. A good portion of any major upgrade is testing and while in the process of testing, I ran into some  Elastic Search issues with our API.
ElasticSearch Logo

What is ElasticSearch?

A document-oriented database that allows you to store, retrieve, and manage document-oriented data through it’s open source API. At gap intelligence, we use it to power faster and efficient searches for information in our massive database of GFD. I wanted to share some useful ElasticSearch commands I  used to help me troubleshoot some API issues.

Check your Elasticsearch Connection

If your ES powered API isn’t returning the expected results, first rule out a connection issue with:

curl -XGET environment_url:9200/
A successful connection will return information about your ES cluster in JSON format.

List All Your Indices

Once  you’ve established your connection works, check your indices and make sure the  ones you’re looking for are there:

curl -XGET environment_url:9200/_cat/indices

Delete an Index:

If you find a bad index and need to remove it, simply delete it with: 

curl -XDELETE environment_url:9200/index_name

Check Your Index Aliases

It helps to verify that your ES requests routes match your index aliases. The following command will return all the aliases for each index:
curl -XGET environment_url:9200/_aliases\?pretty\=true

Test a Query

Check to see if an ES query returns the expected response. If it does, you know the issue isn’t with your ElasticSearch setup:

curl -XGET environment_url:9200/index_name/_search?

Here’s an example with search parameters:

curl -XGET environment_url:9200/index_name/_search\?q\=country_code:US

List your Index Mapping

You can check if the correct fields are being mapped in your indices, as well as the correct types and formats. This can help verify if you’re searching with the correct params in your ES queries.

curl -XGET environment_url:9200/index_name/_mapping


ElasticSearch is a vast, complex, and powerful tool and can sometimes be intimidating to utilize and navigate. Fortunately, their website provides thorough and detailed documentation to help developers implement it into our applications. I found the above commands from that same documentation very helpful while working on our own API and I hope you will find them useful as well.

Do you have what it take to be a gapper? Our Product Development team is hiring. Head to our culture section to learn more about open positions. We’re conducting phone interviews as we work towards flattening the curve. Stay safe and healthy. We’re all in this together.