[{"id":"elasticsearchintermediate-001","courseId":"elasticsearch-intermediate","domain":"data-modeling","topic":"Dynamic mapping of new string fields","prompt":"An index has no mapping yet. You index one document with a city field. Elasticsearch adds the field automatically. What type does it give city?","hint":"The field is new, so Elasticsearch chooses its mapping from the JSON value it receives.","explain":"Elasticsearch adds a field it has not seen before and picks its type from the value it receives. A plain string gets a mapping built for two different jobs: full-text search and exact matching.","source":"https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html","interaction":{"type":"single"},"options":[{"id":"a","text":"text, with a keyword sub-field","why":"Strings that are not dates or numbers get a text field plus a .keyword sub-field for exact values."},{"id":"b","text":"keyword only","whyNot":"Dynamic mapping does not choose keyword alone for strings; it adds a text field with a keyword sub-field."},{"id":"c","text":"text only, with no sub-field","whyNot":"The keyword sub-field is added too, so exact values stay available for sorting and aggregations."},{"id":"d","text":"object, with the value split into sub-fields","whyNot":"Only a JSON object becomes an object mapping; a plain string value does not."}],"answer":"a","explanation":"Dynamic mapping gives a new JSON string that is not a date or a number a text field with a .keyword sub-field, so it can be full-text searched and also matched exactly.","concept":"Dynamic mapping gives a new JSON string that is not a date or a number a text field with a .keyword sub-field, so it can be full-text searched and also matched exactly.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"{\"city\": \"Oslo\"}","takeaways":["Unmapped string fields get text plus a keyword sub-field by default."]},{"id":"elasticsearchintermediate-002","courseId":"elasticsearch-intermediate","domain":"data-modeling","topic":"The dynamic setting false","prompt":"An index sets dynamic to false. A document arrives with a field the mapping does not declare, and Elasticsearch rejects the whole document with an error.","hint":"The dynamic setting decides what happens to a field the mapping does not yet declare.","explain":"The dynamic setting decides what happens to a field the mapping does not declare yet. The options range from adding the field, to skipping it, to refusing the whole document.","source":"https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Setting false skips the new field and keeps the document; rejecting documents is the job of the strict setting."},{"id":"b","text":"False","why":"With false the document is still indexed and only the new field is skipped; the rejection belongs to strict."}],"answer":"b","explanation":"dynamic: false ignores new fields: they are not added to the mapping or indexed, the document is still indexed, and the field remains in _source. Only strict rejects documents with unknown fields.","concept":"dynamic: false ignores new fields: they are not added to the mapping or indexed, the document is still indexed, and the field remains in _source. Only strict rejects documents with unknown fields.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Unknown fields can be added, skipped, or cause rejection, depending on the dynamic setting."]},{"id":"elasticsearchintermediate-003","courseId":"elasticsearch-intermediate","domain":"data-modeling","topic":"Object arrays and cross-object matches","prompt":"A product has a reviews array of objects, each with user and stars, under the default object mapping. A query for user alice AND stars 1 matches a product whose alice review has 5 stars. Why?","hint":"Think about what the default mapping does to the link between the fields of one array element.","explain":"Mapping types decide how the fields of an array of objects are kept in the index. Some layouts lose track of which values belonged together, and that decides which combinations a query can match.","source":"https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html","interaction":{"type":"single"},"options":[{"id":"a","text":"The array is flattened, so the fields of different reviews are mixed together and the link between user and stars is lost.","why":"Under the default object type, the fields of each element are stored as flat multi-value fields, so alice and 1 can come from different reviews."},{"id":"b","text":"The stars field is mapped as text, so the number 1 matches any value containing it.","whyNot":"Numbers are mapped as numeric types, not text, so 1 is compared as a number."},{"id":"c","text":"Each review is stored on its own shard, so matches from different shards are combined.","whyNot":"A document and its array are stored together on one shard; reviews are not spread across shards."},{"id":"d","text":"The match checks only the first review in the array, so the other reviews are never compared.","whyNot":"Every element of the array is part of the indexed fields; the default mapping does not skip later reviews."}],"answer":"a","explanation":"Under the default object type, fields of array elements are flattened, so a query can combine values from different elements. A nested mapping keeps each element as its own hidden document, and a nested query matches within one element.","concept":"Under the default object type, fields of array elements are flattened, so a query can combine values from different elements. A nested mapping keeps each element as its own hidden document, and a nested query matches within one element.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Arrays of objects need the nested type when their fields must match together."]},{"id":"elasticsearchintermediate-004","courseId":"elasticsearch-intermediate","domain":"data-modeling","topic":"The nested type","prompt":"A product has a reviews array of objects, each with user and stars. You declare reviews as nested. Which TWO statements about the nested type are correct?","hint":"Compare how each element is stored with how a query must reach its fields.","explain":"Mapping types decide how an array of objects is laid out in the index, and that layout limits how a query can reach each field. Some layouts cost more to index and query than others.","source":"https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"A plain match on reviews.user finds only values from the same review.","whyNot":"Nested fields cannot be reached outside a nested query, so a plain match does not find them at all."},{"id":"b","text":"Each object in the array is indexed as a separate hidden document.","why":"Nested objects are indexed as separate hidden documents, one per element of the array."},{"id":"c","text":"Nested objects live inside the parent's entry, so no nested query is needed.","whyNot":"Each element is its own hidden document, which is why a nested query is required to reach its fields."},{"id":"d","text":"Its fields can only be searched inside a nested query.","why":"The fields of a nested object are reachable only within the scope of the nested query."},{"id":"e","text":"Every object field is nested by default, so arrays keep their links.","whyNot":"The default is the object type, which flattens arrays; nested has to be declared on the field."},{"id":"f","text":"Nested documents are cheap, so declaring nested everywhere costs little.","whyNot":"Nested documents and queries are typically expensive, so declare nested only where it is needed."}],"answer":"bd","explanation":"The nested type indexes each array element as a separate hidden document, and its fields are reachable only through a nested query. Nested documents and queries are typically expensive.","concept":"The nested type indexes each array element as a separate hidden document, and its fields are reachable only through a nested query. Nested documents and queries are typically expensive.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Declare nested for arrays of objects whose fields must match together."]},{"id":"elasticsearchintermediate-005","courseId":"elasticsearch-intermediate","domain":"data-modeling","topic":"Multi-fields for search and sorting","prompt":"You want users to full-text search product names, and also to sort the results alphabetically by name. Which mapping supports both?","hint":"One indexing style finds words inside a value; another keeps the whole value for ordering.","explain":"A field can be indexed in more than one way at once, each copy suited to a different purpose. Splitting a value helps search, while keeping it whole helps ordering.","source":"https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html","interaction":{"type":"single"},"options":[{"id":"a","text":"Map name as text, and add a keyword sub-field under fields for sorting.","why":"The text field is analyzed for search, and the keyword sub-field keeps the whole value for sorting and aggregations."},{"id":"b","text":"Map name as keyword only, which also supports full-text search.","whyNot":"Keyword stores the whole value for exact matching, sorting and aggregations; it is not the field used for full-text search."},{"id":"c","text":"Map name as text and sort on name directly, since sorting works on any field.","whyNot":"Text is analyzed into pieces rather than kept whole, so sorting uses a keyword field instead."},{"id":"d","text":"Copy name into a second text field with the same settings, and sort on the copy.","whyNot":"A second text field is still analyzed; sorting needs a field that keeps the whole value."}],"answer":"a","explanation":"A multi-field indexes the same value in more than one way: a text field for full-text search, and a keyword sub-field for sorting and aggregations.","concept":"A multi-field indexes the same value in more than one way: a text field for full-text search, and a keyword sub-field for sorting and aggregations.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Search on the text field; sort and aggregate on its keyword sub-field."]}]