Elasticsearch in Action

Elasticsearch in Action

2nd edition

de Madhusudhan Konda (2023)

Manning



A book about the ElasticSearch search engine, widely used for text search and logging across many organizations.



Notes





Active study

  1. Recall concept · cap-1 ●○○

    What technology is Elasticsearch built on?

    Reveal answer

    On Apache Lucene, a Java library for text indexing and search; Solr and OpenSearch also derive from it.

    Source: Notes, ch. 1 — Overview

  2. Recall concept · cap-1 ●○○

    What is the difference between searching structured and unstructured data?

    Reveal answer

    In structured data (with a schema) the result is binary — it matches or not, with no relevance score; in unstructured data (text) one searches for identical and similar terms, with a relevance score.

    Source: Notes, ch. 1 — Overview

  3. Recall relationship · cap-1 ●●○

    Searching for "books published after 2015" and "books about concurrent programming": which is structured and which is not?

    Reveal answer

    The first is structured (a precise filter on a date, yes/no); the second is unstructured text, with relevance.

    Source: Notes, ch. 1 — Overview

  4. Recall relationship · cap-1 ●●○

    Why are relational databases bad for text search?

    Reveal answer

    They are slow to index large volumes of text, have no fuzzy matching or synonyms, search by exact match, and normalization makes searching several fields at once difficult.

    Source: Notes, ch. 1 — Overview

  5. Recall concept · cap-1 ●●○

    What does making a text searchable mean, in essence?

    Reveal answer

    Breaking it into tokens and mapping each token to the full documents that contain it.

    Source: Notes, ch. 1 — Overview

  6. Recall concept · cap-1 ●○○

    What are the components of the Elastic Stack and the role of each?

    Reveal answer

    Beats (ship data from somewhere), Logstash (ETL pipeline that transforms and transfers data), Elasticsearch (the search engine, heart of the stack) and Kibana (UI for visualizing and interacting).

    Source: Notes, ch. 1 — Overview

  7. Multiple choice relationship · cap-1 ●●○

    You need to enrich and transform logs from several sources before indexing them. Which component of the stack do you use?

  8. Recall detail · cap-1 ●●○

    What are the three search scopes of Elastic Enterprise Search?

    Reveal answer

    App Search (an application's internal data), Enterprise/Workplace Search (within the organization) and Site Search (on a website).

    Source: Notes, ch. 1 — Overview

  9. Recall relationship · cap-1 ●●○

    What should Elasticsearch not be used for?

    Reveal answer

    Relational or transactional data, write-heavy workloads, OLAP, many binaries (images, video), low latency and real-time analytics, time series and graphs.

    Source: Notes, ch. 1 — Overview

  10. True or false relationship · cap-1 ●○○

    Elasticsearch is a good choice as the main database of a transactional payments system.

  11. Recall concept · cap-1 ●○○

    How do clients communicate with Elasticsearch?

    Reveal answer

    Through RESTful APIs over HTTP, with JSON — which makes it language-agnostic.

    Source: Notes, ch. 1 — Overview

  12. Recall concept · cap-2 ●○○

    What is the URL format for indexing a document with an ID?

    Reveal answer

    PUT <index>/_doc/<id> with the JSON document in the body (e.g. PUT books/_doc/1).

    Source: Notes, ch. 2 — Getting Started

  13. True or false names-and-dates · cap-2 ●●○

    In current versions, an index can hold several document types (such as books/novel/1).

  14. Recall concept · cap-2 ●●○

    Where does an index's schema come from if no mapping was defined?

    Reveal answer

    It is inferred from the first document indexed (schema-free).

    Source: Notes, ch. 2 — Getting Started

  15. Recall detail · cap-2 ●○○

    How do you count the documents of one index, of several, or of all?

    Reveal answer

    GET books/_count, GET books1,books2/_count or GET _count.

    Source: Notes, ch. 2 — Getting Started

  16. Recall concept · cap-2 ●●○

    How do you fetch several documents by ID at once?

    Reveal answer

    With an ids query in the search API: {"query": {"ids": {"values": [1,2,3]}}}.

    Source: Notes, ch. 2 — Getting Started

  17. Recall detail · cap-2 ●○○

    GET books/_search without a body is equivalent to which query?

    Reveal answer

    To a match_all, which returns all documents.

    Source: Notes, ch. 2 — Getting Started

  18. Recall concept · cap-2 ●●○

    In a match query with several words, what is the default operator and how do you change it?

    Reveal answer

    OR; you can set "operator": "AND" to require all the words.

    Source: Notes, ch. 2 — Getting Started

  19. Recall relationship · cap-2 ●●○

    Why does searching "author": "JOSHUA" find "Joshua Bloch", but "josh" does not?

    Reveal answer

    Analysis normalizes case, so JOSHUA becomes the token joshua; but "josh" is a different token — match does not search prefixes (for that there is the prefix query).

    Source: Notes, ch. 2 — Getting Started

  20. Recall concept · cap-2 ●●○

    How do you search several fields while giving more weight to one of them?

    Reveal answer

    multi_match with fields, using ^ for boost: "fields": ["title^3", "synopsis"].

    Source: Notes, ch. 2 — Getting Started

  21. Recall concept · cap-2 ●●○

    What does match_phrase do, and what is slop for?

    Reveal answer

    It searches for the exact phrase, in order; slop tolerates a number of missing or out-of-order words.

    Source: Notes, ch. 2 — Getting Started

  22. Recall concept · cap-2 ●●○

    What is the fuzziness parameter?

    Reveal answer

    An integer that allows matches up to that Levenshtein distance (character swaps, insertions, deletions) — it tolerates typos.

    Source: Notes, ch. 2 — Getting Started

  23. Multiple choice relationship · cap-2 ●●○

    A user types "Kava" meaning "Java". What feature solves this?

  24. Recall concept · cap-2 ●●○

    Why don't term queries give a meaningful relevance score?

    Reveal answer

    Because they work on structured data with exact matching, without text analysis: the document matches or it doesn't.

    Source: Notes, ch. 2 — Getting Started

  25. Recall concept · cap-2 ●●○

    What are the four clauses of a bool query, and which affect the score?

    Reveal answer

    must (required, counts toward the score), must_not (excludes, no score), should (optional, only increases the score) and filter (required, no score).

    Source: Notes, ch. 2 — Getting Started

  26. Recall relationship · cap-2 ●●●

    You want books by Joshua, preferably tagged "Software", only 3rd edition, and none rated below 4.7. Build the logic of the bool query.

    Reveal answer

    must: match author Joshua; should: match tags Software; filter: term edition 3; must_not: range amazon_rating lt 4.7.

    Source: Notes, ch. 2 — Getting Started

  27. Recall relationship · cap-2 ●●●

    What is the difference between putting a condition in must and in filter?

    Reveal answer

    Both exclude what doesn't match, but filter doesn't contribute to the score (and can be cached); use it for yes/no conditions.

    Source: Notes, ch. 2 — Getting Started

  28. Recall detail · cap-2 ●●○

    How do you get only the result of an aggregation, without the documents?

    Reveal answer

    By setting "size": 0 in the request.

    Source: Notes, ch. 2 — Getting Started

  29. Recall concept · cap-2 ●●○

    What is the difference between metric and bucket aggregations?

    Reveal answer

    Metric aggregations compute statistics (min, max, avg, sum, stats); bucket aggregations split documents into groups (e.g. histogram, ranges).

    Source: Notes, ch. 2 — Getting Started

  30. Recall concept · cap-2 ●○○

    What is the _bulk API for?

    Reveal answer

    For indexing (or operating on) several documents in a single request.

    Source: Notes, ch. 2 — Getting Started

  31. Recall concept · cap-3 ●○○

    What is an index in Elasticsearch?

    Reveal answer

    A logical collection of documents — something like a table in a relational database.

    Source: Notes, ch. 3 — Architecture

  32. Recall concept · cap-3 ●○○

    What is a shard?

    Reveal answer

    An instance of Apache Lucene that holds part of an index's data; an index is divided into primary shards, each with replicas.

    Source: Notes, ch. 3 — Architecture

  33. Recall concept · cap-3 ●●○

    What are the two steps of text analysis during indexing?

    Reveal answer

    Tokenization (breaking the text into tokens, e.g. by whitespace) and normalization (enriching/transforming tokens: lowercasing, stemming, synonyms).

    Source: Notes, ch. 3 — Architecture

  34. Recall relationship · cap-3 ●●●

    Why does the query text also go through analysis?

    Reveal answer

    So that it is tokenized and normalized the same way the documents were indexed; only then do the search tokens match those in the index.

    Source: Notes, ch. 3 — Architecture

  35. Recall concept · cap-3 ●○○

    What is an inverted index?

    Reveal answer

    A structure that maps each token to the documents in which it appears (and how often) — the basis of fast text search.

    Source: Notes, ch. 3 — Architecture

  36. Recall relationship · cap-3 ●●○

    Documents: 1 = "Hello WORLD", 2 = "Hello Mate". What does the inverted index look like with the standard analyzer?

    Reveal answer

    hello → 1, 2; world → 1; mate → 2.

    Source: Notes, ch. 3 — Architecture

  37. Recall detail · cap-3 ●●○

    What structure does Elasticsearch use for non-text data, such as numbers and dates?

    Reveal answer

    BKD trees.

    Source: Notes, ch. 3 — Architecture

  38. Recall concept · cap-3 ●●○

    What are replicas for?

    Reveal answer

    Redundancy (they live on different nodes from the primary and can be promoted if a node goes down) and distributing reads.

    Source: Notes, ch. 3 — Architecture

  39. Recall names-and-dates · cap-3 ●●○

    What is the default number of shards and replicas per index since version 7?

    Reveal answer

    1 primary shard and 1 replica.

    Source: Notes, ch. 3 — Architecture

  40. Recall relationship · cap-3 ●●○

    Why can the number of shards not change in a live index, while the number of replicas can?

    Reveal answer

    Because routing uses hash(id) % number_of_shards; changing the divisor would make documents unfindable. To change it, you have to reindex.

    Source: Notes, ch. 3 — Architecture

  41. Recall relationship · cap-3 ●●●

    An index with 3 shards is full and someone proposes going to 5 shards in the same index. What is the problem and the solution?

    Reveal answer

    It is not possible: routing (hash(id) % 3) would send searches to the wrong shards. The solution is to create an index with 5 shards and reindex into it.

    Source: Notes, ch. 3 — Architecture

  42. Recall concept · cap-3 ●○○

    What do the green, yellow and red states of a cluster mean?

    Reveal answer

    Green: all shards and replicas allocated. Yellow: all primaries available, but some replica is not. Red: some primary shard unavailable.

    Source: Notes, ch. 3 — Architecture

  43. Recall relationship · cap-3 ●●○

    Why does a single-node cluster with 1-replica indexes turn yellow?

    Reveal answer

    Because the replica cannot live on the same node as the primary; without another node, replicas are not allocated.

    Source: Notes, ch. 3 — Architecture

  44. Recall detail · cap-3 ●●●

    What guidelines do the notes give for shard size and count?

    Reveal answer

    Don't exceed about 50 GB per shard and host up to 20 shards per GB of heap.

    Source: Notes, ch. 3 — Architecture

  45. Recall concept · cap-3 ●●○

    Name roles a node can have.

    Reveal answer

    Master (cluster management), data (persistence and search; hot/cold variants), ingest (pipelines before indexing), ML, transform and coordinating (the default, receives client requests).

    Source: Notes, ch. 3 — Architecture

  46. Recall concept · cap-3 ●●○

    What is a data stream?

    Reveal answer

    A feature that works as an alias for automatically generated hidden indexes (e.g. one per day); writes go to the newest index and searches query all of them — ideal for time series and logs.

    Source: Notes, ch. 3 — Architecture

  47. Recall concept · cap-3 ●○○

    What is an alias?

    Reveal answer

    An alternative name for an index or set of indexes.

    Source: Notes, ch. 3 — Architecture

  48. Recall concept · cap-3 ●●○

    What relevance algorithm does Elasticsearch use by default, and what does it take into account?

    Reveal answer

    Okapi BM25, an improved version of TF/IDF: it rewards the term's frequency in the document, rewards terms that are rare in the index and normalizes by field length.

    Source: Notes, ch. 3 — Architecture

  49. Recall relationship · cap-3 ●●●

    Two documents contain "Java" once: one has 10 words, the other 1,000. Which does BM25 tend to score higher?

    Reveal answer

    The short one: normalization by field length avoids favoring long documents, and the occurrence weighs more in a short text.

    Source: Notes, ch. 3 — Architecture

  50. Recall concept · cap-3 ●●○

    What is the difference between scaling Elasticsearch vertically and horizontally?

    Reveal answer

    Vertical: making the machine bigger (CPU, RAM), usually with downtime. Horizontal: adding nodes to the cluster — more practical and recommended.

    Source: Notes, ch. 3 — Architecture

  51. True or false relationship · cap-3 ●●○

    Running several nodes on the same machine is a good way to ensure redundancy.

  52. Recall concept · cap-4 ●○○

    What is an index's mapping?

    Reveal answer

    The schema definition: the fields, their data types and parameters; there is one mapping per index.

    Source: Notes, ch. 4 — Mapping

  53. Recall concept · cap-4 ●●○

    What happens when you PUT a document into an index that does not exist?

    Reveal answer

    The index is created with default settings, a schema is inferred from the document's types (dynamic mapping), and the document is indexed; subsequent documents skip the first steps.

    Source: Notes, ch. 4 — Mapping

  54. Recall relationship · cap-4 ●●○

    Why should dynamic mapping be kept for testing only?

    Reveal answer

    Because it can get things wrong: for example, quoted numbers become strings and dates outside the default format (YYYY-MM-DD) are not recognized.

    Source: Notes, ch. 4 — Mapping

  55. Recall relationship · cap-4 ●●●

    The first document indexed has "price": "19.90" (in quotes). What will dynamic mapping do, and what problem does this cause?

    Reveal answer

    It will infer text (with a keyword subfield), not a number; range searches and numeric aggregations on price won't work as expected.

    Source: Notes, ch. 4 — Mapping

  56. Recall concept · cap-4 ●○○

    What is the difference between the text and keyword types?

    Reveal answer

    text is analyzed (tokenized and normalized) for text search; keyword is not analyzed — the whole value becomes a single token, for exact matches (e.g. an email).

    Source: Notes, ch. 4 — Mapping

  57. Multiple choice relationship · cap-4 ●●○

    What type should be used for an error code field like ERR-4021, searched only by equality?

  58. Recall relationship · cap-4 ●●○

    How do you sort results by a text field?

    Reveal answer

    Better to use a keyword subfield (title.keyword); enabling fielddata: true also works, but is computationally expensive.

    Source: Notes, ch. 4 — Mapping

  59. Recall concept · cap-4 ●●○

    Which APIs are used to define an explicit mapping?

    Reveal answer

    The create index API (PUT employees with mappings) when the index doesn't exist, and the mapping API (PUT employees/_mapping) to update an existing one.

    Source: Notes, ch. 4 — Mapping

  60. True or false concept · cap-4 ●●○

    It is possible to change the type of an existing field with PUT <index>/_mapping.

  61. Recall relationship · cap-4 ●●●

    You need to change a field's type in production without breaking the clients that use the index name. How?

    Reveal answer

    Create a new index with the correct mapping, reindex the data (_reindex API) and point an alias, used by the clients, to the new index.

    Source: Notes, ch. 4 — Mapping

  62. Recall concept · cap-4 ●●○

    What is type coercion?

    Reveal answer

    Elasticsearch slightly adapts the input data to fit the mapping's type, such as accepting "42" in a numeric field.

    Source: Notes, ch. 4 — Mapping

  63. Recall concept · cap-4 ●●○

    What is the token_count type for?

    Reveal answer

    For storing the number of tokens in a text; used as a subfield (e.g. title.word_count) to search, for example, for four-word titles.

    Source: Notes, ch. 4 — Mapping

  64. Recall detail · cap-4 ●●●

    What is the constant_keyword type?

    Reveal answer

    A keyword with a value predefined in the mapping, the same for all documents in the index; it can be omitted when indexing.

    Source: Notes, ch. 4 — Mapping

  65. Recall detail · cap-4 ●●○

    What is the wildcard type for?

    Reveal answer

    For searches with wildcard characters and regex over keyword values (e.g. *obj*).

    Source: Notes, ch. 4 — Mapping

  66. Recall concept · cap-4 ●●○

    What are the range types (such as date_range)?

    Reveal answer

    Fields with a lower and upper bound (e.g. the dates of a course), which can be queried with range queries.

    Source: Notes, ch. 4 — Mapping

  67. Recall concept · cap-4 ●●○

    What does the geo_point type store, and what query does it enable?

    Reveal answer

    Latitude and longitude; it enables searches such as geo_bounding_box.

    Source: Notes, ch. 4 — Mapping

  68. Recall concept · cap-4 ●●●

    What is the limitation of the object type for arrays of objects?

    Reveal answer

    Subfields are flattened into independent arrays, losing the link between values of the same object; a search combining two fields may match values from different objects.

    Source: Notes, ch. 4 — Mapping

  69. Recall relationship · cap-4 ●●●

    A document has [{dish: burger, extra: pickles}, {dish: hotdog, extra: chili}]. Does searching for "burger with chili" return the document?

    Reveal answer

    With the object type, yes (the values are flattened); with nested, no — each object is treated separately.

    Source: Notes, ch. 4 — Mapping

  70. Recall concept · cap-4 ●●○

    What is the nested type?

    Reveal answer

    A specialized form of object that preserves the relationship between the fields of each object in an array; it must be declared in the mapping.

    Source: Notes, ch. 4 — Mapping

  71. True or false detail · cap-4 ●●○

    Elasticsearch has its own array data type.

  72. Recall concept · cap-4 ●●○

    What does the flattened type do?

    Reveal answer

    It indexes all subfields of an object as keywords, without analysis and without declaring them in the mapping; it allows searching any value without knowing the keys.

    Source: Notes, ch. 4 — Mapping

  73. Recall relationship · cap-4 ●●●

    Medical notes come in with unpredictable keys (symptoms, medication, history…) and you only need to search exact values. What type should you use?

    Reveal answer

    flattened: it avoids a mapping explosion and makes any value searchable as a keyword.

    Source: Notes, ch. 4 — Mapping

  74. Recall concept · cap-4 ●●●

    How does the join type work, and what is its downside?

    Reveal answer

    It creates a parent-child relationship between documents in the same index (with routing so they land on the same shard); performance is poor, and it is usually better to leave this to relational databases.

    Source: Notes, ch. 4 — Mapping

  75. Recall concept · cap-4 ●●○

    How does the search_as_you_type type support autocomplete?

    Reveal answer

    It creates subfields automatically: 2- and 3-word shingles (_2gram, _3gram) and edge n-grams (_index_prefix), to match what the user is typing.

    Source: Notes, ch. 4 — Mapping

  76. Recall concept · cap-4 ●●○

    How can a field have several types?

    Reveal answer

    By declaring subfields in fields in the mapping — for example, subject as text, subject.kw as keyword and subject.comp as completion.

    Source: Notes, ch. 4 — Mapping

  77. Recall concept · cap-6 ●○○

    What are the three basic configurations of an index?

    Reveal answer

    Settings (e.g. shards and replicas), mappings (schema) and aliases.

    Source: Notes, ch. 6 — Indexing operations

  78. Recall relationship · cap-6 ●●○

    What is the risk of fully disabling action.auto_create_index?

    Reveal answer

    Breaking tools such as Kibana, which create hidden indexes (starting with a dot) automatically; it is better to allow it selectively by name patterns.

    Source: Notes, ch. 6 — Indexing operations

  79. Recall concept · cap-6 ●●○

    What is the difference between dynamic and static settings?

    Reveal answer

    Dynamic ones can change in a live index; static ones only at creation — to change them you have to close the index or recreate it.

    Source: Notes, ch. 6 — Indexing operations

  80. Recall relationship · cap-6 ●●●

    What are the steps of a zero-downtime index migration?

    Reveal answer

    Clients query through an alias; create the new index with the desired settings; reindex the data; repoint the alias (with _aliases, an atomic remove + add); finally delete the old one.

    Source: Notes, ch. 6 — Indexing operations

  81. Recall concept · cap-6 ●●○

    What is is_write_index for in an alias that points to several indexes?

    Reveal answer

    To indicate which of them receives writes; at least one must be writable.

    Source: Notes, ch. 6 — Indexing operations

  82. Recall concept · cap-6 ●●○

    What happens when you close an index (POST cars/_close)?

    Reveal answer

    It stops accepting reads and writes and frees memory and resources; it can be reopened with _open.

    Source: Notes, ch. 6 — Indexing operations

  83. Recall detail · cap-6 ●●●

    What does action.destructive_requires_name control?

    Reveal answer

    Whether destructive operations (delete, close) require explicit names or accept wildcards and _all.

    Source: Notes, ch. 6 — Indexing operations

  84. Recall concept · cap-6 ●○○

    What is an index template?

    Reveal answer

    Predefined configurations (settings, mappings, aliases) applied automatically to indexes whose name matches a pattern (glob).

    Source: Notes, ch. 6 — Indexing operations

  85. Recall concept · cap-6 ●●○

    What is the difference between a component template and a composable (index) template?

    Reveal answer

    The component is a reusable block of configurations, without an index pattern, which is not a template on its own; the composable one has an index pattern and is made up of zero or more components (composed_of).

    Source: Notes, ch. 6 — Indexing operations

  86. Recall relationship · cap-6 ●●●

    An index matches two templates, with priority 20 and 30, that set the number of replicas differently. Which applies?

    Reveal answer

    The configurations of both are applied, but in a conflict the priority-30 one prevails; explicit configurations at creation beat any template.

    Source: Notes, ch. 6 — Indexing operations

  87. Recall concept · cap-6 ●●●

    What are the conditions for splitting an index?

    Reveal answer

    The index must be read-only (index.blocks.write), the target must not exist, the target's number of shards must be a multiple of the original's and the node must have space.

    Source: Notes, ch. 6 — Indexing operations

  88. Recall concept · cap-6 ●●●

    What are the conditions for shrinking an index?

    Reveal answer

    Read-only source, all shards on the same node, nonexistent target, target's number of shards a factor of the original's and enough memory on the node.

    Source: Notes, ch. 6 — Indexing operations

  89. Multiple choice relationship · cap-6 ●●○

    An index has 3 shards. To which number can it be split?

  90. Recall concept · cap-6 ●●○

    What does rolling over an alias do?

    Reveal answer

    It makes the current index read-only, creates a new index with an incremented name (e.g. -000002) and repoints the alias to it; the data is not copied.

    Source: Notes, ch. 6 — Indexing operations

  91. Recall relationship · cap-6 ●●●

    Application logs arrive continuously and you want a new index whenever the current one goes over 10 GB or one day. How do you set this up?

    Reveal answer

    An ILM policy with a rollover action (max_size, max_age) in the hot phase, attached via a template (with rollover_alias) to indexes matching the pattern, and an initial writable index on the alias.

    Source: Notes, ch. 6 — Indexing operations

  92. Recall concept · cap-6 ●○○

    What are the phases of an index's life cycle in ILM?

    Reveal answer

    Hot (read and write), warm (read-only, frequent queries), cold (read-only, rare and slow queries), frozen (very rare and very slow) and delete.

    Source: Notes, ch. 6 — Indexing operations

  93. True or false detail · cap-6 ●●○

    The hot phase is the only mandatory one in an ILM policy.

  94. Recall relationship · cap-6 ●●●

    Why might an ILM action not happen at the exact expected moment?

    Reveal answer

    Because policies run as a background task, checked every 10 minutes by default.

    Source: Notes, ch. 6 — Indexing operations

  95. Recall concept · cap-5 ●○○

    When do you index with PUT and when with POST?

    Reveal answer

    PUT when the client provides the ID (PUT movies/_doc/1); POST when the ID should be generated by the server (a UUID).

    Source: Notes, ch. 5 — Working with documents

  96. Recall concept · cap-5 ●●○

    How do you avoid overwriting an existing document when indexing?

    Reveal answer

    By using _create (PUT movies/_create/100), which errors if the ID already exists; the regular _doc overwrites.

    Source: Notes, ch. 5 — Working with documents

  97. Recall concept · cap-5 ●●○

    What happens to a document between indexing and becoming searchable?

    Reveal answer

    It goes into the shard's in-memory buffer; at each refresh (1 s by default) the documents become a segment with an inverted index, searchable, and are later persisted to disk.

    Source: Notes, ch. 5 — Working with documents

  98. Recall concept · cap-5 ●●●

    How does Lucene manage segments over time?

    Reveal answer

    It merges segments — three at a time — into larger segments, recursively; deleted documents are only marked and actually removed during merges.

    Source: Notes, ch. 5 — Working with documents

  99. Recall relationship · cap-5 ●●○

    Why is Elasticsearch said to be eventually consistent?

    Reveal answer

    Because an indexed document only becomes searchable after the next refresh, not immediately.

    Source: Notes, ch. 5 — Working with documents

  100. Recall relationship · cap-5 ●●○

    What is the trade-off of lowering the refresh interval?

    Reveal answer

    Documents become searchable sooner, but frequent refreshes are expensive in I/O.

    Source: Notes, ch. 5 — Working with documents

  101. Recall relationship · cap-5 ●●●

    You are going to load 10 million documents at once. What should you do with refresh?

    Reveal answer

    Disable it (or greatly increase the interval) during the load and re-enable it at the end, making everything searchable at once and saving I/O.

    Source: Notes, ch. 5 — Working with documents

  102. Recall detail · cap-5 ●●●

    What are the values of the ?refresh parameter when indexing?

    Reveal answer

    true (searchable immediately), false (default) and wait_for (the request waits for the next refresh).

    Source: Notes, ch. 5 — Working with documents

  103. Recall detail · cap-5 ●○○

    How do you check only whether a document exists?

    Reveal answer

    HEAD movies/_doc/1.

    Source: Notes, ch. 5 — Working with documents

  104. Recall concept · cap-5 ●●○

    How do you fetch several documents by ID, including from different indexes?

    Reveal answer

    With _mget: in one index, {"ids": [...]}; in several, a docs list with each one's _index and _id.

    Source: Notes, ch. 5 — Working with documents

  105. Recall concept · cap-5 ●●○

    How do you control what comes back in the response to a document GET?

    Reveal answer

    _source instead of _doc returns only the document without metadata; ?_source=false returns only metadata; _source_includes and _source_excludes filter fields.

    Source: Notes, ch. 5 — Working with documents

  106. Recall concept · cap-5 ●●○

    What does the _update API do behind the scenes?

    Reveal answer

    It fetches the document, modifies it and reindexes it — it is a replacement.

    Source: Notes, ch. 5 — Working with documents

  107. Recall concept · cap-5 ●●○

    What are the parts of an update script?

    Reveal answer

    source (the logic, e.g. ctx._source.actors.add(...)), lang (painless is the default) and params (values passed dynamically).

    Source: Notes, ch. 5 — Working with documents

  108. Recall relationship · cap-5 ●●●

    Why pass values in params instead of hardcoding them in the script?

    Reveal answer

    Because scripts are compiled on first execution, which is expensive; with parameters, the same compiled script is reused for different values.

    Source: Notes, ch. 5 — Working with documents

  109. Recall concept · cap-5 ●●○

    How does upsert work?

    Reveal answer

    If the document doesn't exist, it inserts the content of upsert; if it exists, it applies the update script.

    Source: Notes, ch. 5 — Working with documents

  110. Recall relationship · cap-5 ●●●

    What does doc_as_upsert: true do in a partial update?

    Reveal answer

    If the document doesn't exist, it creates it with the content of doc, instead of erroring.

    Source: Notes, ch. 5 — Working with documents

  111. Recall concept · cap-5 ●●○

    How do you update several documents without knowing their IDs?

    Reveal answer

    With _update_by_query: a query selects the documents and a script modifies them; there is version checking with retry, and only the documents with errors fail to be updated.

    Source: Notes, ch. 5 — Working with documents

  112. Recall concept · cap-5 ●●○

    How do you delete documents by criteria?

    Reveal answer

    With _delete_by_query, which accepts any query (ranges, bool etc.); with match_all it deletes everything. Deletion is irreversible.

    Source: Notes, ch. 5 — Working with documents

  113. Recall concept · cap-5 ●●○

    What is the format of a _bulk request?

    Reveal answer

    NDJSON: for each operation, an action and metadata line (index, create, update, delete with _index and _id) followed, when applicable, by a line with the document.

    Source: Notes, ch. 5 — Working with documents

  114. Recall relationship · cap-5 ●○○

    Why use _bulk instead of indexing document by document?

    Reveal answer

    To save bandwidth and requests when operating at scale.

    Source: Notes, ch. 5 — Working with documents

  115. Recall concept · cap-7 ●○○

    What are the three components of an analyzer, and how many of each can there be?

    Reveal answer

    Character filters (zero or more), exactly one tokenizer, and token filters (zero or more), in that order.

    Source: Notes, ch. 7 — Text analysis

  116. Multiple choice relationship · cap-7 ●●○

    In an analyzer, which component removes HTML tags before breaking up the text?

  117. Recall relationship · cap-7 ●●○

    What tokens come out of <h2>Hello WORLD</h2> with html_strip, the whitespace tokenizer and lowercase?

    Reveal answer

    hello and world.

    Source: Notes, ch. 7 — Text analysis

  118. Recall concept · cap-7 ●○○

    What is the _analyze endpoint for?

    Reveal answer

    For testing analyzers, tokenizers and filters on ad hoc text, without changing indexes or the cluster.

    Source: Notes, ch. 7 — Text analysis

  119. Recall concept · cap-7 ●●○

    What is the standard analyzer like?

    Reveal answer

    The default: no character filters, the standard tokenizer (whitespace, grammar, punctuation) and the lowercase and stop token filters — the latter disabled by default.

    Source: Notes, ch. 7 — Text analysis

  120. Recall relationship · cap-7 ●●●

    With the standard analyzer, what happens to "Hot cup of ☕ and a 🍿 is a Weird Combo :(!!"?

    Reveal answer

    They become lowercase tokens; emojis such as ☕ and 🍿 are kept as tokens, but ":(" and "!!" are removed; stop words ("of", "a") remain.

    Source: Notes, ch. 7 — Text analysis

  121. Recall concept · cap-7 ●●○

    What does the simple analyzer do?

    Reveal answer

    Only a lowercase tokenizer, which splits on any non-letter (spaces, hyphens, numbers), with no filters.

    Source: Notes, ch. 7 — Text analysis

  122. Recall relationship · cap-7 ●●●

    What tokens does the simple analyzer produce for "Lukša's K8s in Action"?

    Reveal answer

    lukša, s, k, s, in, action: the apostrophe and the number 8 become separators.

    Source: Notes, ch. 7 — Text analysis

  123. Recall concept · cap-7 ●●○

    What does the keyword analyzer do?

    Reveal answer

    It uses a noop tokenizer: the whole text becomes a single token, with no filters; it requires an exact match.

    Source: Notes, ch. 7 — Text analysis

  124. Recall concept · cap-7 ●●○

    What does the fingerprint analyzer do, and what is it for?

    Reveal answer

    It removes duplicates, sorts the words and produces a single token; useful for detecting duplicate items.

    Source: Notes, ch. 7 — Text analysis

  125. Recall relationship · cap-7 ●●○

    What tokens does a pattern analyzer splitting on hyphens produce for "1234-5678-9000-0000"?

    Reveal answer

    1234, 5678, 9000, 0000.

    Source: Notes, ch. 7 — Text analysis

  126. Recall relationship · cap-7 ●●●

    Why can a language analyzer's stemming get in the way, and how do you fix it?

    Reveal answer

    It can be too aggressive: "authorization" and "authority" both become "author", making them indistinguishable; stem_exclusions is used.

    Source: Notes, ch. 7 — Text analysis

  127. Recall concept · cap-7 ●●○

    How do you enable stop words in the standard analyzer?

    Reveal answer

    By defining in the index settings an analyzer of type standard with "stopwords": "_english_" (or a custom list/file).

    Source: Notes, ch. 7 — Text analysis

  128. Recall concept · cap-7 ●●○

    How do you create a custom analyzer?

    Reveal answer

    In the index settings, an analyzer with "type": "custom", listing the desired char_filter, tokenizer and filter.

    Source: Notes, ch. 7 — Text analysis

  129. Recall concept · cap-7 ●●○

    At what levels is the indexing analyzer defined?

    Reveal answer

    At the index (analysis.analyzer.default, applies to all text fields) or at the field (in the mapping).

    Source: Notes, ch. 7 — Text analysis

  130. Recall concept · cap-7 ●●●

    In what order does Elasticsearch choose the analyzer at search time?

    Reveal answer

    1) the query's; 2) the field's search_analyzer; 3) the index's default search_analyzer; 4) the field's or index's indexing analyzer.

    Source: Notes, ch. 7 — Text analysis

  131. Recall relationship · cap-7 ●●●

    A field has analyzer: stop and search_analyzer: simple, and the query does not specify an analyzer. Which one analyzes the search text?

    Reveal answer

    simple: the field's search_analyzer takes priority over the indexing analyzer.

    Source: Notes, ch. 7 — Text analysis

  132. Recall concept · cap-7 ●●○

    What are the three types of character filter?

    Reveal answer

    HTML strip (removes tags), mapping (swaps characters/terms, e.g. UK → United Kingdom) and pattern replace (replaces by regex).

    Source: Notes, ch. 7 — Text analysis

  133. Recall concept · cap-7 ●●○

    What are the bigrams and the edge n-grams of "coffee"?

    Reveal answer

    Bigrams: co, of, ff, fe, ee. Edge n-grams: c, co, cof, coff, coffe, coffee — anchored at the start of the word.

    Source: Notes, ch. 7 — Text analysis

  134. Recall relationship · cap-7 ●●●

    For an autocomplete that suggests "elasticsearch" when the user types "elas", which tokenizer should be used at indexing?

    Reveal answer

    Edge n-gram: it indexes the prefixes, so "elas" matches the generated token.

    Source: Notes, ch. 7 — Text analysis

  135. Recall detail · cap-7 ●●○

    What are the uax_url_email and path_hierarchy tokenizers for?

    Reveal answer

    uax_url_email keeps URLs and emails as tokens; path_hierarchy breaks hierarchical paths (folders) at the separators.

    Source: Notes, ch. 7 — Text analysis

  136. Recall concept · cap-7 ●●○

    What does the shingle token filter do?

    Reveal answer

    It generates word n-grams (not character ones): "James Bond" → ["james", "james bond", "bond"]; by default of 1 and 2 words.

    Source: Notes, ch. 7 — Text analysis

  137. Recall concept · cap-7 ●●○

    How does the synonym token filter work?

    Reveal answer

    It turns words into their synonyms based on a list, inline or in a file.

    Source: Notes, ch. 7 — Text analysis

  138. Recall concept · cap-8 ●●○

    What is the difference between precision and recall?

    Reveal answer

    Precision is the density of relevant documents among those returned; recall is how much of the existing relevant documents was returned.

    Source: Notes, ch. 8 — Introducing search

  139. Recall relationship · cap-8 ●●●

    How does enabling synonyms and fuzziness in a search tend to affect precision and recall?

    Reveal answer

    It tends to increase recall (finds more relevant documents) and reduce precision (more irrelevant results come in).

    Source: Notes, ch. 8 — Introducing search

  140. Recall concept · cap-8 ●●○

    What is the role of the coordinating node in a search?

    Reveal answer

    To find the nodes with relevant shards, ask them to run the query, receive the partial results, aggregate them and respond to the client. Any node can be a coordinator.

    Source: Notes, ch. 8 — Introducing search

  141. Recall concept · cap-8 ●●○

    What is the difference between query context and filter context?

    Reveal answer

    Query context computes a relevance score; filter context only decides whether the document is included, without a score, saving resources and using the cache.

    Source: Notes, ch. 8 — Introducing search

  142. Recall concept · cap-8 ●●○

    What is a URI request search, and what are its limitations?

    Reveal answer

    Searching with parameters in the URL (?q=title:Godfather); it supports boolean operators, ranges and default_operator, but is less flexible than the Query DSL.

    Source: Notes, ch. 8 — Introducing search

  143. Recall concept · cap-8 ●○○

    What is the difference between a leaf query and a compound query?

    Reveal answer

    A leaf query has a single criterion; a compound query combines several leaf queries with conditions.

    Source: Notes, ch. 8 — Introducing search

  144. Recall concept · cap-8 ●●○

    How does result pagination work, and what is the default limit?

    Reveal answer

    With size (default 10) and from; the default maximum is 10,000 results (adjustable, but not recommended). For many results, search_after is more efficient.

    Source: Notes, ch. 8 — Introducing search

  145. Recall relationship · cap-8 ●●●

    You need to go through 2 million documents from a search. Why not use from/size?

    Reveal answer

    Because deep from is expensive (each page requires sorting everything before it) and hits the 10,000 limit; use search_after.

    Source: Notes, ch. 8 — Introducing search

  146. Recall concept · cap-8 ●○○

    What does highlighting do?

    Reveal answer

    It highlights, in the specified fields, the passages that matched the search, by default wrapping them in <em> tags.

    Source: Notes, ch. 8 — Introducing search

  147. Recall concept · cap-8 ●●○

    What does explain: true do in a search?

    Reveal answer

    It explains how each result's score was computed (boost × IDF × TF); there is also the _explain API.

    Source: Notes, ch. 8 — Introducing search

  148. Recall relationship · cap-8 ●●○

    What happens to _score when sorting by another field?

    Reveal answer

    It is not computed, unless track_scores: true is used; additional sort fields serve as tie-breakers.

    Source: Notes, ch. 8 — Introducing search

  149. Recall concept · cap-8 ●●○

    What options are there for controlling the fields returned in a search?

    Reveal answer

    _source: false (omits the document), fields (a subset of fields, accepts wildcards), _source with includes/excludes and script_fields (fields computed by a script).

    Source: Notes, ch. 8 — Introducing search

  150. Recall concept · cap-8 ●●○

    What is indices_boost for?

    Reveal answer

    To prioritize results from certain indexes, multiplying the score of each index's documents by a coefficient.

    Source: Notes, ch. 8 — Introducing search

  151. Recall concept · cap-9 ●○○

    What are the characteristics of term-level queries?

    Reveal answer

    They do exact matching on structured data (numbers, dates, keywords), without going through the analyzer — the term is looked up directly in the inverted index; they are cheaper.

    Source: Notes, ch. 9 — Term-level search

  152. Recall relationship · cap-9 ●●●

    Why does term: {title: "The Godfather"} on a text field probably return nothing?

    Reveal answer

    Because the field was analyzed and indexed as separate lowercase tokens ("the", "godfather"); the term query does not analyze and looks for the exact string, which doesn't exist in the index.

    Source: Notes, ch. 9 — Term-level search

  153. True or false relationship · cap-9 ●●○

    In a term query, uppercase and lowercase make a difference.

  154. Recall concept · cap-9 ●●○

    What does the terms query do?

    Reveal answer

    It searches for several values in the same field, with OR logic (e.g. certificate in ["PG-13", "R"]); the maximum number of terms is configurable (default 2^16).

    Source: Notes, ch. 9 — Term-level search

  155. Recall concept · cap-9 ●●●

    What is a terms lookup?

    Reveal answer

    A terms query whose values come from a field of another document (index, id, path), instead of a fixed list.

    Source: Notes, ch. 9 — Term-level search

  156. Recall concept · cap-9 ●●○

    What is the exists query for?

    Reveal answer

    For returning documents in which a field exists; combined with must_not, it finds those that lack the field.

    Source: Notes, ch. 9 — Term-level search

  157. Recall concept · cap-9 ●○○

    What does the range query do, and which operators does it use?

    Reveal answer

    It searches for values within bounds with gt, gte, lt and lte; it accepts date expressions such as now-1y.

    Source: Notes, ch. 9 — Term-level search

  158. Recall relationship · cap-9 ●●○

    How do you search for movies released in the last year?

    Reveal answer

    range on release_date with "gte": "now-1y".

    Source: Notes, ch. 9 — Term-level search

  159. Recall concept · cap-9 ●●○

    What are the operators of the wildcard query, and what is its cost?

    Reveal answer

    * (zero or more characters) and ? (one character); it is expensive and can be blocked with search.allow_expensive_queries: false.

    Source: Notes, ch. 9 — Term-level search

  160. Recall concept · cap-9 ●●●

    How do you speed up prefix queries?

    Reveal answer

    By setting index_prefixes in the field's mapping: the prefixes (by default from 2 to 5 characters) are pre-indexed, avoiding computing them at search time.

    Source: Notes, ch. 9 — Term-level search

  161. Recall relationship · cap-9 ●●●

    With the default index_prefixes, which prefixes are pre-indexed for "Gladiator"?

    Reveal answer

    "Gl", "Gla", "Glad", "Gladi" (from 2 to 5 characters).

    Source: Notes, ch. 9 — Term-level search

  162. Recall concept · cap-9 ●●●

    How does fuzziness: auto work?

    Reveal answer

    It sets the edit distance by the term's length: 0–2 characters → 0; 3–5 → 1; more than 5 → 2. It is the default of the fuzzy query.

    Source: Notes, ch. 9 — Term-level search

  163. Multiple choice relationship · cap-9 ●●○

    With fuzziness: auto, how many edits are tolerated for the term "rama"?

  164. Recall concept · cap-10 ●●○

    What would a match_none query be for?

    Reveal answer

    To deliberately return no results, combined with application logic — for example, during maintenance, instead of erroring.

    Source: Notes, ch. 10 — Full-text searches

  165. Recall concept · cap-10 ●●○

    In a match with the OR operator, how do you require at least some of the words to match?

    Reveal answer

    With minimum_should_match, which sets the minimum number of terms that must match.

    Source: Notes, ch. 10 — Full-text searches

  166. Recall concept · cap-10 ●○○

    Are the terms of a match query analyzed?

    Reveal answer

    Yes: they go through the analyzer (by default the same as at indexing, with lowercase), unlike term-level queries.

    Source: Notes, ch. 10 — Full-text searches

  167. Recall relationship · cap-10 ●●●

    What is the difference between match with the AND operator and match_phrase?

    Reveal answer

    AND requires all the words in any order and position; match_phrase requires the words together, in the same sequence (relaxable with slop).

    Source: Notes, ch. 10 — Full-text searches

  168. Recall concept · cap-10 ●●○

    What does match_phrase_prefix do?

    Reveal answer

    Like match_phrase, but the last word can be just a prefix: "Concepts and found" matches "Concepts and foundations".

    Source: Notes, ch. 10 — Full-text searches

  169. Recall concept · cap-10 ●●○

    What is the default type of multi_match, and how does it compute the score?

    Reveal answer

    best_fields: the score is that of the best-matching field, ignoring the others; there are also cross_fields, most_fields, phrase and phrase_prefix.

    Source: Notes, ch. 10 — Full-text searches

  170. Recall concept · cap-10 ●●●

    Which query does multi_match use behind the scenes, and what is tie_breaker for?

    Reveal answer

    dis_max, which runs one query per field and keeps the best score; tie_breaker multiplies the scores of the other fields and adds them, serving as a tie-breaker.

    Source: Notes, ch. 10 — Full-text searches

  171. Recall relationship · cap-10 ●●●

    Two books have "Design Patterns" in the title with the same score, but only one also has it in the synopsis. How do you make the second field count?

    Reveal answer

    Use a tie_breaker (e.g. 0.3) in the dis_max/multi_match: the score of the fields that are not the best now counts partially.

    Source: Notes, ch. 10 — Full-text searches

  172. Recall concept · cap-10 ●●○

    What is the query_string query, and what is its downside?

    Reveal answer

    A query with operator syntax (AND, OR, NOT, fields, ranges, ~ for fuzzy), useful for advanced user searches; it is strict about syntax and throws an exception if the input is malformed.

    Source: Notes, ch. 10 — Full-text searches

  173. Recall relationship · cap-10 ●●○

    When should you prefer simple_query_string to query_string?

    Reveal answer

    When the input comes from the user and you don't want syntax errors: it accepts few operators (e.g. + for AND) and suppresses syntax errors.

    Source: Notes, ch. 10 — Full-text searches

  174. Multiple choice relationship · cap-10 ●●●

    A public search box receives free text with unbalanced quotes and parentheses. Which query avoids 400 errors?

  175. Recall concept · cap-11 ●○○

    What are the five types of compound query?

    Reveal answer

    bool, constant_score, function_score, boosting and dis_max.

    Source: Notes, ch. 11 — Compound queries

  176. Recall relationship · cap-11 ●●●

    How does the behavior of should change when there is no must?

    Reveal answer

    It starts working as a filter: minimum_should_match goes from 0 to 1, so at least one should clause must match.

    Source: Notes, ch. 11 — Compound queries

  177. Recall concept · cap-11 ●●●

    What are named queries for in a bool query?

    Reveal answer

    For naming each leaf query; the response indicates which of them matched in each result.

    Source: Notes, ch. 11 — Compound queries

  178. Recall concept · cap-11 ●●○

    What is the constant_score query for?

    Reveal answer

    For wrapping a filter and assigning a fixed (non-zero) score to the results, bypassing relevance computation.

    Source: Notes, ch. 11 — Compound queries

  179. Recall concept · cap-11 ●●○

    How does the boosting query work?

    Reveal answer

    It has a positive part (what to return) and a negative one (what to demote); results matching the negative part have their score multiplied by negative_boost.

    Source: Notes, ch. 11 — Compound queries

  180. Recall relationship · cap-11 ●●●

    You want to list all TVs, but show those above US$2,500 further down, without excluding them. Which query should you use?

    Reveal answer

    boosting: positive = product TV; negative = range price > 2500, with a negative_boost of, for example, 0.5.

    Source: Notes, ch. 11 — Compound queries

  181. Recall concept · cap-11 ●●○

    What does the function_score query allow?

    Reveal answer

    Defining a custom score: random (random_score, with a seed), by script (script_score) or by a field's value (field_value_factor).

    Source: Notes, ch. 11 — Compound queries

  182. Recall relationship · cap-11 ●●●

    You want TVs with better user ratings to come first, without writing a script. What should you use?

    Reveal answer

    function_score with field_value_factor on user_ratings (optionally with a factor or a modifier such as square).

    Source: Notes, ch. 11 — Compound queries

  183. Recall concept · cap-11 ●●●

    What do score_mode and boost_mode control in function_score?

    Reveal answer

    score_mode defines how to combine the scores of several functions; boost_mode, how to combine them with the query's score (multiplication by default; also sum, avg, min, max, replace).

    Source: Notes, ch. 11 — Compound queries

  184. Recall concept · cap-12 ●○○

    What are the three main geo queries, and what does each search for?

    Reveal answer

    geo_bounding_box (within a rectangle defined by two corners), geo_distance (within a circle of given radius around a point) and geo_shape (shapes in relation to another shape).

    Source: Notes, ch. 12 — Advanced search

  185. Multiple choice relationship · cap-12 ●●○

    An app wants to list restaurants within 2 km of the user. Which query should it use?

  186. Recall detail · cap-12 ●●○

    In what formats can a geo_point be given?

    Reveal answer

    A "lat, lon" string, a {lat, lon} object, an array (longitude first), WKT (POINT(lon lat)) or a geohash.

    Source: Notes, ch. 12 — Advanced search

  187. Recall concept · cap-12 ●●○

    Which spatial relations does the geo_shape query support?

    Reveal answer

    intersects (default, any point in common), within (entirely inside), contains (contains the query's shape) and disjoint (outside).

    Source: Notes, ch. 12 — Advanced search

  188. Recall relationship · cap-12 ●●●

    You want the land plots entirely inside a neighborhood polygon, excluding those that cross the border. Which relation should you use?

    Reveal answer

    within; the default intersects would also include plots that only touch or cross the border.

    Source: Notes, ch. 12 — Advanced search

  189. Recall concept · cap-12 ●●○

    What is the shape query for?

    Reveal answer

    For searching 2D shapes on a Cartesian plane (e.g. technical drawings), not a geographic one — for example, all shapes within an envelope.

    Source: Notes, ch. 12 — Advanced search

  190. Recall concept · cap-12 ●●○

    What is the difference between a regular query and a span query?

    Reveal answer

    The regular one asks whether the document contains "apple" and "pie"; the span one considers position: "apple" immediately followed by "pie", or within 3 words.

    Source: Notes, ch. 12 — Advanced search

  191. Recall detail · cap-12 ●●○

    What do span_first, span_near and span_within do?

    Reveal answer

    span_first: a term among the first n words. span_near: terms within n positions of each other (with slop and in_order). span_within: a term surrounded by two others.

    Source: Notes, ch. 12 — Advanced search

  192. Recall relationship · cap-12 ●●●

    How do you find quotes in which "plato" appears before "aristotle", with up to 3 words between them?

    Reveal answer

    span_near with two span_terms (plato, aristotle), slop: 3 and in_order: true.

    Source: Notes, ch. 12 — Advanced search

  193. Recall concept · cap-12 ●●○

    What does the distance_feature query do?

    Reveal answer

    It boosts the score of documents closer to an origin (location or date), with a distance pivot.

    Source: Notes, ch. 12 — Advanced search

  194. Recall concept · cap-12 ●●○

    What is the pinned query for?

    Reveal answer

    For pinning certain documents (by ID) to the top, regardless of the organic search score — for example, sponsored results.

    Source: Notes, ch. 12 — Advanced search

  195. Recall concept · cap-12 ●●○

    What does the more_like_this query do?

    Reveal answer

    It searches for documents similar to a given text or document, in the specified fields.

    Source: Notes, ch. 12 — Advanced search

  196. Recall concept · cap-12 ●●●

    How does the percolate query invert the usual logic of search?

    Reveal answer

    Instead of indexing documents and searching them with queries, queries are indexed in a percolator index and you search with a document, finding out which queries it satisfies.

    Source: Notes, ch. 12 — Advanced search

  197. Recall relationship · cap-12 ●●●

    Users searched for a book that didn't exist; now it has arrived in stock. How do you notify them?

    Reveal answer

    Store those searches in a percolator index; when indexing the new book, run a percolate query with it to find the searches it satisfies and notify their authors.

    Source: Notes, ch. 12 — Advanced search

  198. Recall concept · cap-13 ●○○

    What are the three types of aggregation?

    Reveal answer

    Metric (sums, averages, minimum…), bucket (grouping documents into intervals/categories) and pipeline (operating on the result of other aggregations).

    Source: Notes, ch. 13 — Aggregations

  199. Recall relationship · cap-13 ●●○

    What happens when you combine query and aggs in the same request?

    Reveal answer

    The aggregations are computed over the documents that match the query.

    Source: Notes, ch. 13 — Aggregations

  200. Recall relationship · cap-13 ●●●

    Why does aggregating on a text field give an error, and what is the workaround?

    Reveal answer

    Text fields have no doc values for aggregation; you can enable fielddata in the mapping, but it is expensive — the best is to aggregate on the keyword subfield.

    Source: Notes, ch. 13 — Aggregations

  201. Recall concept · cap-13 ●●○

    What do the stats, extended_stats and cardinality aggregations return?

    Reveal answer

    stats: several statistics at once (min, max, avg, sum, count); extended_stats: even more (variance, deviation…); cardinality: the number of unique values.

    Source: Notes, ch. 13 — Aggregations

  202. Recall concept · cap-13 ●●○

    How do you define the buckets of a histogram?

    Reveal answer

    By a fixed interval (interval) or by manual ranges (ranges); for dates, date_histogram with calendar_interval (calendar-aware) or fixed_interval.

    Source: Notes, ch. 13 — Aggregations

  203. Recall relationship · cap-13 ●●●

    You want to count customers in age bands 0–18, 18–30, 30–60, 60+. histogram or range?

    Reveal answer

    range: the bands have different widths; histogram only creates fixed-size intervals.

    Source: Notes, ch. 13 — Aggregations

  204. Recall relationship · cap-13 ●●●

    Why use calendar_interval: 1M instead of fixed_interval: 30d for monthly sales?

    Reveal answer

    Because months have different lengths; calendar_interval respects calendar months, while a fixed 30 days misaligns the buckets.

    Source: Notes, ch. 13 — Aggregations

  205. Recall concept · cap-13 ●●○

    What is a sub-aggregation?

    Reveal answer

    An aggregation nested inside a bucket — for example, the average rating within each year of a date_histogram.

    Source: Notes, ch. 13 — Aggregations

  206. Recall concept · cap-13 ●●○

    What does the terms aggregation (and multi_terms) do?

    Reveal answer

    It creates one bucket per value of a field (e.g. one per author); multi_terms groups by combinations of several fields.

    Source: Notes, ch. 13 — Aggregations

  207. Recall concept · cap-13 ●●○

    What is the difference between parent and sibling aggregations?

    Reveal answer

    Parent operates inside another aggregation (e.g. average per day, nested); sibling runs in parallel, at the same level, over the same set (e.g. average and histogram side by side).

    Source: Notes, ch. 13 — Aggregations

  208. Recall concept · cap-13 ●●○

    What does the cumulative_sum pipeline do?

    Reveal answer

    It is a parent pipeline that computes the running total of a metric across buckets (e.g. cappuccinos sold up to each day), referencing it through buckets_path.

    Source: Notes, ch. 13 — Aggregations

  209. Recall relationship · cap-13 ●●●

    How do you find the day with the most cappuccino sales, and how do you reference the metric?

    Reveal answer

    With a max_bucket sibling pipeline whose buckets_path is sales_by_coffee>cappuccino_sales — the > separates the bucket aggregation from the metric.

    Source: Notes, ch. 13 — Aggregations

  210. Recall concept · cap-14 ●●○

    How do you find out why a shard was not allocated?

    Reveal answer

    With GET _cluster/allocation/explain, giving the index, shard and whether it is primary; the response brings the deciders' decisions (e.g. same_shard: there is already a copy on the node).

    Source: Notes, ch. 14 — Administration

  211. Recall relationship · cap-14 ●●○

    What happens when a second node joins a single-node cluster?

    Reveal answer

    Shards are reallocated automatically: replicas, previously unallocated, come to exist on the new node and some primaries may be moved to it.

    Source: Notes, ch. 14 — Administration

  212. Recall relationship · cap-14 ●●○

    Does increasing replicas improve reads, writes or both?

    Reveal answer

    Only reads: replicas serve queries, but every write must be done on the primary and replicated, which can even weigh more.

    Source: Notes, ch. 14 — Administration

  213. Recall detail · cap-14 ●○○

    What are Elasticsearch's default communication ports?

    Reveal answer

    9200 for HTTP (REST) clients and 9300 for communication between nodes (transport).

    Source: Notes, ch. 14 — Administration

  214. Recall relationship · cap-14 ●●●

    An index has 10 shards of 30 GB, each with 2 replicas. How much space does it need at minimum?

    Reveal answer

    900 GB: 10 primaries × 30 GB = 300 GB, plus 20 replicas × 30 GB = 600 GB — replicas require the same resources as primaries.

    Source: Notes, ch. 14 — Administration

  215. Recall concept · cap-14 ●●○

    What are snapshots in Elasticsearch?

    Reveal answer

    Incremental backups of one index, several or the whole cluster (including templates and ILM policies), in a local or cloud repository (e.g. S3), restored via _restore.

    Source: Notes, ch. 14 — Administration

  216. Recall concept · cap-14 ●●○

    What is SLM for?

    Reveal answer

    Snapshot Lifecycle Management (_slm): it automates snapshots with scheduling and retention policies; it can be triggered manually.

    Source: Notes, ch. 14 — Administration

  217. Recall relationship · cap-14 ●●●

    How do snapshots help change settings that cannot be altered in a live index?

    Reveal answer

    You create a new index with the right settings, snapshot the old one and restore the data into the new one.

    Source: Notes, ch. 14 — Administration

  218. Recall concept · cap-14 ●●○

    What are Elasticsearch's three configuration files?

    Reveal answer

    elasticsearch.yml (basic settings: cluster name, ports, paths), log4j2.properties (log levels) and jvm.options (heap and JVM).

    Source: Notes, ch. 14 — Administration

  219. Recall relationship · cap-14 ●●○

    What rules apply to configuring the JVM heap?

    Reveal answer

    Never edit the original jvm.options — create a .options file in jvm.options.d — and never set -Xms/-Xmx above 50% of the node's RAM.

    Source: Notes, ch. 14 — Administration

  220. Recall relationship · cap-14 ●●●

    When raising the log level to DEBUG to investigate a problem, why use a transient setting?

    Reveal answer

    So that the change does not persist after the cluster restarts, going back to INFO without having to remember to undo it.

    Source: Notes, ch. 14 — Administration

  221. Recall concept · cap-14 ●●○

    What is a master-eligible node, and how is the master chosen?

    Reveal answer

    A node that can become master; the master is chosen by election among them at startup or when the current one goes down. Only the master changes the cluster state and communicates it to the others.

    Source: Notes, ch. 14 — Administration

  222. Recall concept · cap-14 ●●●

    What is the master quorum, and why are at least three master-eligible nodes recommended?

    Reveal answer

    The minimum number of master-eligible nodes (half + 1) that must agree to elect the master or confirm the cluster state; with three or more, split brain — two simultaneous masters during a network failure — is avoided.

    Source: Notes, ch. 14 — Administration

  223. Recall relationship · cap-14 ●●●

    With 5 master-eligible nodes, what is the quorum?

    Reveal answer

    3 (5/2 + 1, rounding the half down).

    Source: Notes, ch. 14 — Administration

  224. Recall relationship · cap-14 ●●○

    Why is it a good idea to have dedicated master nodes?

    Reveal answer

    Because nodes can take on several roles, but at a performance cost; the master is critical and should not compete for resources with data and searches.

    Source: Notes, ch. 14 — Administration

  225. Recall concept · cap-15 ●●○

    What hardware measures help search speed?

    Reveal answer

    SSDs and plenty of memory; a heap of about half the node's RAM (less garbage collection); evenly sized shards, since many small shards increase communication between nodes.

    Source: Notes, ch. 15 — Performance and troubleshooting

  226. Recall relationship · cap-15 ●●○

    Why should data in Elasticsearch be denormalized?

    Reveal answer

    Because it is NoSQL and does not do joins efficiently: each document should be self-sufficient, with no hierarchy between documents.

    Source: Notes, ch. 15 — Performance and troubleshooting

  227. Recall concept · cap-15 ●●●

    How do you avoid searching many fields at once?

    Reveal answer

    By using copy_to in the mapping to combine several fields into one and searching that field — cheaper than a multi_match over many fields.

    Source: Notes, ch. 15 — Performance and troubleshooting

  228. Recall relationship · cap-15 ●●○

    Why does using keyword for exact searches improve performance?

    Reveal answer

    Because it skips the text analysis step.

    Source: Notes, ch. 15 — Performance and troubleshooting

  229. Recall concept · cap-15 ●●○

    What measures speed up indexing?

    Reveal answer

    System-generated IDs (no need to check uniqueness), the bulk API (with a size limit), refresh disabled or less frequent during the load and tuning the thread pools.

    Source: Notes, ch. 15 — Performance and troubleshooting

  230. Recall relationship · cap-15 ●●●

    What is the trade-off of using IDs generated by Elasticsearch?

    Reveal answer

    It indexes faster, since it doesn't need to check whether the ID already exists, but it is liable to duplicate documents that would be the same.

    Source: Notes, ch. 15 — Performance and troubleshooting

  231. Recall concept · cap-15 ●●○

    What are the three disk watermarks, and what happens at each one?

    Reveal answer

    Low (85%): the node stops receiving new shards. High (90%): shards start being relocated to other nodes. Flood stage (95%): the node's indexes become read-only until space is freed.

    Source: Notes, ch. 15 — Performance and troubleshooting

  232. Multiple choice relationship · cap-15 ●●○

    A node is at 96% disk usage and writes start to fail. What happened?

  233. Recall concept · cap-15 ●●○

    What are Elasticsearch's circuit breakers for?

    Reveal answer

    For blocking operations that would exceed memory limits, returning an error before executing them, instead of bringing the node down with an out-of-memory error.

    Source: Notes, ch. 15 — Performance and troubleshooting

  234. Recall detail · cap-15 ●●●

    Name types of circuit breaker and their default limits.

    Reveal answer

    Parent (70% of the heap, with real memory), request (60%), fielddata (40%), in-flight requests and accounting (inherit from parent) and script compilation (150 compilations every 5 min).

    Source: Notes, ch. 15 — Performance and troubleshooting

  235. Recall relationship · cap-15 ●●○

    What happens to reads and writes when there are unallocated primary shards?

    Reveal answer

    They are blocked for those shards until they are properly allocated — the RED state is an emergency.

    Source: Notes, ch. 15 — Performance and troubleshooting

See all questions (235)

Transparency note AI was used in this post for: generating the study questions · creating the English version