Ease your life with Elastic App Search
Tags: elasticsearch, cloud, devrel, community
Published: 2020-03-27 10:06:47

Whenever you come across a word **search** what are the things come in your mind? You might think of Google Search, search for any particular object around you, searching for a particular product on Amazon... etc. When we say search we can observe that in today's digital world, there are many novel ways people are using search as a service.

### But, What is Search?
Search in our case is looking in (a database or the World Wide Web) using various algorithms for the **systematic retrieval of information.**

So, If you have noticed nearly every app you are using or website you are browsing has it's own search bar which uses various services to provide you a way to systematically extract the required information which involves things like sorting, filters, keyword matching etc. 

Now consider you want to build a search engine for your web-app. How complicated that task will be? Here, Elastic App Search comes into picture to ease your life. 

## What is App Search?
App Search is a search-as-a-service solution designed to simplify the process of building rich, user-facing search experiences. It leverage the incredible power of Elasticsearch and focuses squarely on powering search experiences in software applications of every kind — from ecommerce websites, to SaaS applications and mobile apps. 

## What are the key benefits?
What are the additional things you get with App Search apart from plug and play solution? Developers using App Search are able to build search experiences much faster, due to three key factors:

1. `Simple Implementation`: features such as schemaless indexing and built-in typo tolerance, in conjunction with a library of first-party API Clients, enables developers to be up-and-running in minutes.
2. `Cloud-Based SaaS Model`: no need for on-premise deployment, infrastructure provisioning, or long-term maintenance. Simply create an account and get started immediately.
3. `Seamless Scalability`: App Search is designed to scale seamlessly and painlessly as your usage increases.

Let's explore App Search and find more about it:
You can setup app search using following steps.

### Step 1: Creating App Search Deployment:

There are two ways to do this:

1. You can go on switype website and [sign up](https://app.swiftype.com/signup?product=as&utm_channel=as-overview_footer&utm_source=swiftype-web) for free trial.

Below is the screenshot of how it looks:

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/swiftype.png)


After signing up you will be redirected to normal on-boarding process where you can create new engine if you want else they have demo engine setup for you on dashboard which uses national park datasets. You can explore the functionality using that!

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/swiftype-dash.png)

2. Second way will be using Elastic Cloud hosted App Search deployment. Which you can do from elastic cloud console with few clicks as shown below. You can avail 30 days free trial by signing up [here.](http://ela.st/community-trial)

![Alt Text](https://s3.amazonaws.com/fininity.tech/Blog_images/ezgif.com-video-to-gif.gif)

Now, We will be using App Search deployment on elastic cloud for demo though it doesn't really matter as both will be offering same features.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/login.png)

### Step 2: Create an Engine
You can create new engine from app search dashboard. To create an engine, locate and click the **“Create an Engine”** button from your account home page. An engine in App Search is analogous to an index in Elasticsearch. It serves as a container for the documents you index, dataset- level configurations such as weights and boosts, as well as the search analytics that App Search automatically collects for you as users perform searches on the content in that index.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/create-engine.png)

### Step 3: Indexing Documents
Once you create engine you will get an option to index documents as shown below.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/upload.png)

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/doc-import.png)

There are three ways to send documents to your Engine for indexing. You can paste raw JSON, upload a .json file, or POST to the [Documents API endpoint.](https://swiftype.com/documentation/app-search/guides/indexing-documents) 

You have to get your API credentials from credentials tab to use third method.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/keys.png)

The Documents API can be used to add new documents to your Engine, update documents, retrieve documents by id, and delete documents. There are a variety of client libraries to help you get started.

To see the API in action, you can experiment with the example request available on dashboard.

For the movies dataset we will be using it looks like below:

```python
curl -X POST 'https://host-7s23ap.api.swiftype.com/api/as/v1/engines/rent-a-car/documents' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer api-3958sdlfjadsf' \
-d '[
    {
      "title":"An Innocent Magdalene",
      "year":1916,
      "cast":["Lillian Gish","Spottiswoode Aitken"],
      "genres":["Drama"]
    }
  ]'
```

### step 4: Let's test our engine
Again there are multiple ways to test your engine. We will be using readily available query tester from App Search Dashboard.
This is how it looks:

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/qt.png)

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/qt-2.png)

Now we know how to create an App Search engine. Let's explore various  features elastic app search offers us:

1. `Robust APIs`: As we saw above we can use powerful, adaptable, intuitive APIs for indexing, searching, managing our search engine and lot more.

2. `Language clients`: Just index your data using one of the well-maintained API clients — spanning multiple languages and platforms. And easily add search using Search UI.

While creating engine we can choose from number of languages available else we can keep it universal. This provides the essential robustness to this service and this brings us to our third feature.

3. `Language-optimized engines`: We can implement search specifically tuned for a variety of different languages.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/lang.png)

4. `Reference UI`: App Engine provides you a functionality to create reference UI as below so you can test how search will look in case of your application. It's downloadable React application which you can tweak according to your requirements and directly use in your web-app or e-commerce application.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/reference-ui.png)

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/reference-ui-results.png)

5. `Powerful relevance`: help us to take advantage of typo-tolerance, bi-grams, stemming, and more, right out of the box.
you can see this features below:

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/relevance-tuning.png)

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/relevance-tuning-mod.png)

6. `Real-time analytics`: Leverage invaluable insight into user behavior to curate a better search experience.
Analytics plays a very important role if you are implementing this service for any business as that gives you an understanding of user requirements. Analytics comes handy though use of this data varies as per industry or use case.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/analytics.png)

7. `Curated search`: We can use weights, boosts, and synonyms to make the search experience unique to your application. You can observe this in movie-search engine we have created below.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/curations.png)

8. `synonyms`: App engine provides us an option to set synonyms as well. Which helps to provide robust search results.

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/syno.png)

![Alt Text](https://s3.amazonaws.com/fininity.tech/elastic+app+search/qt-after-syno.png)

Here's the link to movies dataset I used in case you want to explore more: https://raw.githubusercontent.com/prust/wikipedia-movie-data/master/movies.json


### What's next?
Isn't this interesting and super cool? It's the easiest way to Search through any data from any application using any interface. So what you are planning to build with this? Let me know in the comments. The only limit is your imagination. If you have any questions you can hit me up on [twitter](https://twitter.com/Jayesh_Ahire1)!


#### References:
1. Switype App Search Documentation: https://swiftype.com/documentation/app-search/getting-started
2. Elastic Blog: https://www.elastic.co/blog/elastic-app-search-is-now-generally-available
3. Elastic Blog on GA: https://www.elastic.co/blog/elastic-app-search-now-available-on-elasticsearch-service?baymax=rtp&elektra=blog&storm=rtp-sidebar&rogue=everyone&iesrc=ctr
4. Dataset: https://github.com/jdorfman/awesome-json-datasets