Elastic App Search

CT Solutions
Geek Culture
Published in
5 min readOct 8, 2021
Elastic App Search

Elastic App search is the product that provides powerful search, aggregation, and analytics capabilities as a Service, on top of Elasticsearch

It brings the focused power of Elasticsearch to your company website, eCommerce site, or apps with a refined set of APIs and intuitive dashboards. Get seamless scalability, tunable relevance controls, thorough documentation, well-maintained clients, and robust analytics to build a leading search experience for your customers.

Elastic App Search is packaged with Workplace Search as a single solution named Elastic Enterprise Search.

Elastic Enterprise Search can be deployed on Elastic Cloud or run the solution on-premises

Installation

Prerequisites

  • Download and install one of the supported JDKs for Enterprise Search.
  • You’ll need to get Elasticsearch up and running with security features enabled

Setting up Elastic Enterprise Search

  1. Download the current version of Elastic Enterprise Search, and navigate to the uncompressed directory.
  2. Locateconfig/enterprise-search.yml and add the following configuration:elasticsearch.username: elastic
    elasticsearch.password: ELASTIC_USER_PASSWORD allow_es_settings_modification: true
    Replace ELASTIC_USER_PASSWORD with the elastic user password.
  3. You must also set at least one encryption key in the sameconfig/enterprise-search.yml configuration file (256-bit key recommended) as an array:secret_management.encryption_keys: [ENCRYPTION_KEY_1, ENCRYPTION_KEY_2, …]
  4. Start Enterprise Search by specifying a password for the defaultenterprise_search user:
    $ ENT_SEARCH_DEFAULT_PASSWORD=passwordexample bin/enterprise-search
    This is an important step. The environment variableENT_SEARCH_DEFAULT_PASSWORDis only used once by Enterprise Search to provision the default enterprise_search user password the first time the product starts.
  5. Log in to the Elastic Enterprise Search experience athttp://localhost:3002using the enterprise_search username and the password previously specified at start time.
  6. From the Elastic Enterprise SearchHome area, select the product experience that fits your use case best from the following :
Elastic Enterprise SearchHome area

Features

App Search simplifies Search use cases for clients, providing abstractions on top of Elasticsearch, providing refined APIs and dashboards. Below you can see App Search features in a nutshell.

  • Engines: An engine in App Search is analogous to an index in Elasticsearch. It is a collection of documents with a customizable schema, relevance, result settings, synonyms, and curations. 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.
collection of documents
  • Index: Once you create an engine you will get an option to index documents
    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.

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

API credentials
  • Search: App Search provides users with document search enabling easy configure grouping, aggregations, filtering, relevance, and result fields tuning. Text matching options like prefix and bigram search are provided by default.
  • Relevance Tuning: In-App Search, clients can tune the relevance of their queries. Relevance Tuning and be performed either on engine or query level and helps us to take advantage of typo-tolerance, bi-grams, stemming, and more, right out of the box
  • Synonyms: App Search provides us an option to set synonyms to relate queries together as well. Synonyms in App Search work a bit differently than in Elasticsearch Which helps to provide robust search results
  • Curations: Users can use weights, boosts, and synonyms to make the search experience unique to your application and curate search results promoting or hiding documents for specific query keywords.
  • Query Suggestions: App Search can provide query suggestions for incomplete queries.
  • Analytics: It Provides APIs and dashboards to get and monitor search result analytics. 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 dashboard
  • UI Support: App Search provides you the functionality to create references so you can test how the search will look in the case of your application. it is possible to configure custom search UIs and export them as React Applications
  • Language-optimized engines: We can implement search specifically tuned for a variety of different languages.
  • Robust APIs: As we saw above we can use powerful, adaptable, intuitive APIs for indexing, searching, managing our search engine, and lot more
  • In addition to REST API, App Search provides official clients for the programming languages below:
  1. JavaScript
  2. Node.js
  3. PHP
  4. Python
  5. Ruby

Node.js Implementation

There are two ways to do it

1. App Search Node.js client

The Elastic App Search Node.js client extends Node.js with an App Search API. This can be used directly from the GitHub link provided by them.

2. Using the elastic app REST APIs directly :

REST APIs implementations

Copy code from here

async createEngine(name) {
const response = await axios.post(elastic_url, {
"name": name
}, {
headers: {
Authorization: `Bearer ${private_key}`,
},
});
return response.data
}
async deleteEngine(ENGINE_NAME) {
try {
const data = await axios.delete(`${elastic_url}/${ENGINE_NAME}`, body, {
headers: {
Authorization: `Bearer ${private_key}`,
}
});
return data
} catch (error) {
console.log(error);
return error
}
}
async getEngineList() {
const response = await axios.get(elastic_url, {
headers: {
Authorization: `Bearer ${private_key}`,
}
});
return response.data.results
}
async createDocument(body, engine) {
const response = await axios.post(`${elastic_url}/${engine}/documents`, body, {
headers: {
Authorization: `Bearer ${private_key}`,
},
});
return response.data
}
async updateDocument(body, engine) {
const response = await axios.patch(`${elastic_url}/${engine}/documents`, body, {
headers: {
Authorization: `Bearer ${private_key}`,
},
});
return response.data
}
async deleteDocument(productId, engine) {
const response = await axios.delete(`${elastic_url}/${engine}/documents`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${private_key}`,
},
data: [
productId
]
});
return response.data
}

In conclusion, If you are using search in your application and you want to focus on application building rather than search engine handling you should definitely make use of all the features provided by elastic app search, It is easy to integrate, implement and maintain allowing us to leverage those strengths while still creating a more turnkey experience for our users.

--

--

CT Solutions
Geek Culture

Driven by the zeal to bring in a change in the digital world, Catalyst Technology Solutions will evolve your brand globally.