Elasticsearch, cut back on your JavaScript

One of my favorite things about Elasticsearch is how it fits into the technology ecosystem. Elasticsearch has proven to be very helpful in not only accomplishing a great search, but also it helps to alleviate some of the work when building a new site/web app.

Take a JavaScript based search for example. My shop uses AngularJS, and we love it. I just wish our front end developer didn’t have to tediously handle data categories for each new set of data we get. That means copy-paste, parsing strings, worrying about commas, escaping characters.

This is done for every piece of data that is different and new.

With Elasticsearch getting a search up and running can be fast and efficient. Instead of parsing strings and escaping characters, we get right into actually categorizing the data.

Say I have some shoe products I’d like to create a search for. First thing is to get my data into a JSON format, Elasticsearch likes to be fed JSON.

About that JSON, it has categories. Elasticsearch likes categories, so much that it has its own name for them. They’re called “Types”.

So we have shoes:

ID Product_Name Type Price
1 Moon Walkers Boot $50
2 Air Jordans Running $100


Here is the first row from the above table in JSON:


“ID”: “1,”,

“Product_Name”: “Moon Walkers”,

“Type”: “Boot”,

“Price”: “$50.00”



Now that the data is stored in Elasticsearch, let’s dig a little deeper as to how Elasticsearch can speed up search creation.

Elasticsearch mostly deals with Types when concerned with data. Instead of a heavy amount of JavaScript, you can send an AJAX request to Elasticsearch for particular type(s). Then, in javascript, your only concern would be filtering the returned text values using a text box!


Ok, I could show a bit more on how to actually do this!

In Elasticsearch, commands are JSON strings. Say we wanted to get all shoes with the type “Boot”. We’d do something like this:

GET /_search


“query”: {

“type” : {

“value” : “Boot”





Imagine a list if checkboxes, of shoe types, “Boot”, “Running”, etc… When a user clicks a check box, we make an ajax call to Elasticsearch, getting data by type. The returned data is then filtered in a JavaScript text box, in our case, AngularJS.




So, your JavaScript and Elasticsearch can work in tandem.

  • Elasticsearch gets your data
  • JavaScript filters the data by text

Rolling out a new search this way is much faster than pure JavaScript on the searching and filtering.

ElasticSearch – Taking The NoSQL Plunge

I cannot tell a lie!

I have fallen in love with ElasticSearch. The ELK (ElasticSearch, Logstash & Kibana) Stack to be exact. Why?

UI: As I developer spending a lot of time on the back end and the middle end, we don’t think about how were going to get that sexy user interface up and running. In my case, the team is small, we have one UI developer, so time is of the essence. Out the box, Kibana provides a fantastic user interface. The UI is mostly mostly point and click. Think Google Analytics with statistical functions built into the UI for you to manipulate.

NoSQL: Never been interested in a game of darts, but ElasticSearch is the ultimate “dart board”. I can throw any record, with any fields without having to worry about matching table structure. Sure, we could right apps that database alter tables, but this is A.D. not B.C!

Data Injection: I’m a sucker for CSV files. Simple and convenient. But an SQL statement to get the same data is even better. Logstash allows you inject your data into ElasticSearch with ease, via different methods, like the two aforementioned.