Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What types of queries does ElasticSearch support?

Answer»

Elasticsearch supports a wide range of queries. The query begins with a query keyword, which is followed by conditions and filters in the form of a JSON object. Here are a few of the queries:

  • Match All Query: This is a basic query that retrieves all the documents in the specified index.
  • Full-text queries: There are high-level queries for executing full-text searches over full-text fields. Full-text queries usually work depending on the analyzer associated with a particular document or index. Full-text queries can be of different types, such as match query, multi-match query, query-string query, ETC.
  • Term Level Queries: Instead of full-text field searches, term-level queries deal with structured data like numbers, enums, dates, etc. Term level queries can be of different types, such as range, exists, prefix, wildcard, fuzzy, type, etc.
Conclusion

In recent years, it has evolved into one of the most popular search engines that are USED for business analytics, LOG analytics, security intelligence, operational intelligence, full-text searches, etc. Research has shown that Elasticsearch has a market share of about 0.24%, so there is a lot of opportunity for many renowned companies. Thus, you are still able to advance in your career as an ElasticSearch Engineer. Almost every area of ElasticSearch, along with the ELK stack, has been covered in the interview questions, including questions about the analyzers, filters, tokenizers, index, token filters, and APIs used in ElasticSearch.

Here, we have compiled a LIST of insightful interview questions that give ample information vital to the interview process. Being familiar with these frequently ASKED interview questions increases your chances of getting hired.

Hopefully, we have answered any questions or concerns that you may have had. All the best with your future endeavours.

Additional Interview Preparation Resources
  • AWS Interview Questions
  • SQL Interview Questions
  • REST API Interview Questions
  • Other Technical Interview Questions
2.

Explain Query DSL in ElasticSearch.

Answer»

Elasticsearch generally provides a QUERY Domain Specific Language (DSL) BASED on JSON to DEFINE queries. Query DSL contains two kinds of clauses:

  • Leaf query clause: A leaf query clause looks for specific values in a field or fields. They can be used independently. Matches, terms, and range queries are some examples of these queries.
  • Compound query clause: A compound query clause is a combination of a leaf query and other compound queries. These queries combine multiple queries to produce their intended results.

The BEHAVIOUR of query clauses differs depending on whether it is used in a filter CONTEXT or a query context.

3.

How can we perform a search in Elasticsearch?

Answer»

Below are a few ways to PERFORM a SEARCH in Elasticsearch:

  • Applying search API: You can search and aggregate data that is stored in Elasticsearch data streams and indices using the search API.
  • Search using a URI (Uniform Resource IDENTIFIER): The search request is executed using a URI (Uniform Resource Identifier) by providing request parameters.
  • Request body search: The search request should be executed using DSL (DOMAIN Specific Language) within the body.
4.

Does ElasticSearch have a schema?

Answer»

Yes, it is possible for ELASTICSEARCH to have a schema. The schema is a description of one or more fields in a document that DESCRIBE what type of document it is and how different fields of a document are to be HANDLED. In Elasticsearch, a schema describes the fields in JSON documents, their data types, and how they should be indexed in the Lucene indexes. As such, we CALL this schema a "mapping" in Elasticsearch.ch.

But Elasticsearch can also be schema-less, MEANING that documents can be indexed without the need to provide a schema explicitly.  If a mapping isn't specified, Elasticsearch will by default generate one when newly added fields are detected during indexing.

5.

What do you mean by aggregation in ElasticSearch?

Answer»

Aggregations in Elasticsearch ENABLE you to group data and calculate statistics on your data with a simple search query. In ElasticSearch, aggregations are categorized into three TYPES:

  • Bucket aggregations: Documents can be grouped into buckets by USING bucket aggregations. You can use them to CREATE data buckets or group data. A bucket can be formed based on existing field values, ranges, etc.
  • Metric aggregations: This aggregation HELPS to calculate metrics (such as a sum, or average) based on field values.
  • Pipeline aggregations: This type of aggregation takes inputs from the output results of other aggregates rather than individual documents or fields.
6.

Is it necessary to install X-Pack for Elasticsearch? What are some essential X-pack commands?

Answer»

Yes, if you are using ElasticSearch, you must INSTALL X-Pack. In essence, X-Pack is an Elastic Stack extension that combines or bundles alerting, REPORTING, monitoring, security, and graph capabilities into a single package that can be installed quickly and easily. ALTHOUGH the components of the X-Pack work seamlessly together, you can enable or disable the features you need. SINCE X-Pack is an Elastic Stack extension, you will need to install both Elasticsearch and Kibana before installing X-Pack. The version of X-Pack must match Elasticsearch and Kibana versions.

The following are a few X-Pack commands that can help you configure security and perform other TASKS:

  • elasticsearch-certgen
  • elasticsearch-certutil
  • elasticsearch-reset-password
  • elasticsearch-setup-passwords
  • elasticsearch-syskeygen
  • elasticsearch-users, etc.
7.

What configuration management tools does Elasticsearch support?

Answer»

ELASTICSEARCH supports the following CONFIGURATION MANAGEMENT TOOLS:

  • Chef: cookbook-elastic search.
  • Puppet: puppet-elastic search.
  • Ansible: ansible-elastic search.
8.

Explain ELK stack and its architecture.

Answer»

The "ELK" acronym refers to three open-source products i.e., Elasticsearch, Logstash, and Kibana, which are all produced, managed, and maintained by ELASTIC company. With the introduction of Beats, this stack became a four-legged project called BELK or Elastic Stack.

  • ElasticSearch: Elasticsearch is an open-source, modern, full-text search engine BASED or built on Apache Lucene. ElasticSearch enables you to store, search, and analyze vast or huge amounts of data in near real-time, providing results in milliseconds.
  • Logstash: Logstash is a data processing pipeline tool, which COLLECTS data from different sources, performs several transformations and enhancements, and then sends the data to stash or wherever you want it to go. 
  • Kibana: Kibana is a visualization tool built on top of Elasticsearch, enabling users to analyze and view data. The Kibana dashboard lets you visualize complex queries through interactive diagrams, geospatial data, and graphs.
  • Beats: Beats are lightweight data shipping agents (data shippers) that collect different types of data and forward it to Logstash or ElasticSearch. There are different types of Beats, each focused on a specific type of data, such as metrics, log files, network packets, audit data, Windows events, uptime monitoring data, and cloud data.

These components are typically used in conjunction to monitor, troubleshoot, and SECURE IT environments. The Beats and Logstash tools handle the collection and processing of data, while Elasticsearch stores and indexes the data, and Kibana provides a graphical UI (user interface) for querying and visualizing the data.

9.

What are the different ElasticSearch commands available in the cat API?

Answer»

There are different commands available in the Elasticsearch cat API. Here are a few:

  • Count: Displays the total NUMBER of documents in your cluster.
GET _cat/count?v
  • Allocation: Displays the disk space allocated to indices and the number of SHARDS per node.
GET _cat/allocation?v
  • Field data: SHOWS the memory usage of each field per node.
GET _cat/fielddata?v
  • Indices: Displays information about indices, INCLUDING how much space they take up, how many shards they have, etc.
GET _cat/indices?v
  • Node Attributes: Displays the attributes associated with custom nodes.
GET _cat/nodeattrs?v
10.

Describe the functionality of the cat API in ElasticSearch.

Answer»

Elasticsearch API results are USUALLY displayed in JSON format, which is not always easy to read. Human eyes require compact and aligned text, especially when looking at a TERMINAL. In order to meet this need, cat APIs (compact and aligned text APIs) have been developed. Thus, the cat APIs feature offered by Elasticsearch facilitates an easier-to-read and comprehend printing format for Elasticsearch results. Cat APIs return plain text instead of traditional JSON, which is comprehensible by users. You can view the available operations in the cat API by running the following commands:

GET _cat

Additionally, you may use the following parameters with your query.

  • Verbose (v?): Gives results in a nice format or more verbose OUTPUT. Use this parameter to see what each column represents.
    • Syntax:
GET _cat/<operation_name>?v
  • Help (?help): Provides a list of the available headers and COLUMNS for a given operation. You can view all available headers by using this parameter.
    • Syntax:
GET _cat/<operation_name>?help
  • Headers (?h): Limit the output to specified headers or columns in the command.
    • Syntax:
GET _cat/<operation_name>?h=<header_name_1>,<header_name_2>&v
  • Numeri format (?format): Provide different types of numeric output, such as bytes, size, and time VALUE.
  • Sort (?sort): Sorts the table by the specified columns as the parameter value.
11.

What is an Inverted index in ElasticSearch?

Answer»

ElasticSearch utilizes a hashmap-like data structure known as an inverted index that allows for rapid full-text searches. The inverted index lists all the unique words that appear in one or more documents and identifies all the documents those words appear in. With it, you can conduct QUICK searches across millions of documents to find relevant data.

Example: Let's assume we have TWO different documents:

  • Scaler is a good Ed-tech company.
  • InterviewBit is one of the good companies.

The above texts have been tokenized first into separate terms for indexing purposes. All the unique terms are then stored in the index, along with information such as which DOCUMENT the term appears in, its position, as WELL as how many times it appeared. ACCORDINGLY, the inverted index is as follows:

TermFrequencyDocumentDocument: Position
Scaler111:1
is21,21:2,2:2
a111:3
good21,21:4,2:6
Ed-tech111:5
Company111:6
InterviewBit122:1
one122:3
of 122:4
the122:5
companies122:7

Let's say you are looking for a term company or companies. With this inverted index, queries can search for terms and quickly identify documents that contain these terms.

12.

What is an Analyzer ElasticSearch?

Answer»

When indexing DATA in ELASTICSEARCH, the data is internally TRANSFORMED by the Analyzer assigned to the index. In essence, an analyzer indicates how text should be indexed and searched in ElasticSearch. Elasticsearch comes with several ready-to-use analyzers built into it. You can also CREATE custom analyzers by combining the built-in CHARACTER filters, tokenizers, and token filters.

  • Character filter: Used to remove unused characters or change some characters.
  • Tokenizer: Divides or breaks text into tokens (or words) based on some criteria (e.g. whitespace).
  • Token filter: The filter receives tokens and applies filters to them (such as changing uppercase terms into lowercase).
13.

Explain Tokenizer in ElasticSearch.

Answer»

When a tokenizer receives a STREAM of characters (text), it tokenizes them (usually by breaking them up into individual words or tokens), and OUTPUTS the stream of words/tokens. Elasticsearch COMES with several tokenizers that you can use to build your custom ANALYZERS. A whitespace tokenizer, for example, breaks text into individual tokens whenever it encounters any whitespace. The text "Scaler by InterviewBit!" would be converted into terms or tokens [Scaler, by, InterviewBit].