Elastic Search Client Library

Mar 22, 2017 00:00 · 687 words · 4 minutes read Objective-C Swift development xcode elastic search

When I first heard of Elastic Search from my friend, I imagined it to be an easily scalable search engine from the word elastic. I was fascinated by hearing great features of this smart engine. Here is a little trivia about this amazing technology. Elastic Search is an open source distributed, RESTful search engine, developed by Shay Banon. It is a multi-tenant system, reliable and scalable.

We all use Google for searching, when we do a search query we get the results a few fraction of seconds, ever wondered what goes behind the scenes to implement such a robust and efficient system? I was intrigued by the possibility of setting up such a powerful search engine in our applications. Imagine that you have a system or an application with huge data and you want to provide search feature to the customers of the application so that they can retrieve the data by searching. As an example let’s consider that you have a file storing application where users can store their files and mark each of them as public or private, public files are visible to all the users of the application and private files are visible only to the user.

Now, say you want to provide a search feature to this application so that users can search the documents or full-text search of their files or public files. This problem statement comes with a bunch of other problems like reliability, efficiency, and scalability. Let us see what these additional problems are. The system we’re trying to develop should be resilient to these additional problems in order to make it robust. It should be reliable, meaning it shouldn’t fail under any circumstances, no single point of failure or system crash etc. It should be efficient, we don’t want the search to take more than few milliseconds to retrieve the results if so no one is going to use the system. Let us imagine that we have implemented the search and now suddenly your application is a huge success and there is a sudden increase in traffic in terms of users. The system should be able to scale to serve the users. Scalability is the primary issue of many applications and services. So, our idea of adding simple search to the application has got so many twists. One way to get away with this problem is to use well-known search engines, Elastic Search is one of them.

Elastic search is a distributed system, the best part of any distributed system is it can be easily extended to provide reliability as there won’t be any single point failures and is also scalable as we can add more machines to multiple it’s capabilities. Elastic Search indexes the shards (a horizontal partition of the database), it maintains one or more replicas of shards so that the operations can be performed in any of these shards. It provides multi-tenancy with multi-types by having more than one index or sharing the indexes across the tenants. It provides RESTful and Java APIs (as it is written in Java). The motivation behind the RESTful API is to provide a common interface to use by other programming languages. It is document oriented so no need for upfront schema, the schema can be defined per type for customization of the indexing process. It provides Real-Time search, meaning we can search in the data that is just added, Elastic Search provides Near Real Time Search, with the development of per-segment search, the delay between indexing a document and making it visible to search is dropped drastically. More importantly, it is an open source project, which introduces it to a large developer community.

Coming to what I’m working on, I’m developing the Elastic Search Client Library for iOS, it was the initial idea of my friend Siddharth at AppBase to create client-side libraries. The library essentially creates an object reference to the server for writing, reading, and streaming data using the RESTful APIs of the search engine. AppBase GitHub has already few libraries (JS, Android and iOS) that are available. Please take a look at them. Thanks for reading :)