Given the following Elasticsearch mapping and document indexing, what will be the type of the age field in the index?
{
"mappings": {
"dynamic": true
}
}
Document:
{
"name": "Alice",
"age": 30
}Dynamic mapping tries to guess the field type based on the value.
With dynamic mapping enabled, Elasticsearch detects the age field as a number and maps it as long automatically.
Given this explicit mapping and a document, what will be the type of the price field?
{
"mappings": {
"properties": {
"price": { "type": "keyword" }
},
"dynamic": true
}
}
Document:
{
"price": 19.99
}Explicit mappings override dynamic mapping for specified fields.
Explicit mapping for price as keyword takes precedence, so dynamic mapping does not change it.
Consider this mapping and document indexing attempt:
{
"mappings": {
"dynamic": "strict"
}
}
Document:
{
"title": "Book",
"pages": 250
}What error will Elasticsearch raise when indexing this document?
Strict dynamic mapping forbids new fields not defined explicitly.
With dynamic": "strict", Elasticsearch rejects documents with fields not in the mapping, raising strict_dynamic_mapping_exception.
Which of the following best explains why explicit mapping can improve Elasticsearch search performance?
Think about how knowing field types helps Elasticsearch.
Explicit mapping lets Elasticsearch know field types and analyzers in advance, so it can index and search more efficiently.
Given this mapping and document, how many fields will be indexed?
{
"mappings": {
"dynamic": false,
"properties": {
"user": { "type": "keyword" },
"message": { "type": "text" }
}
}
}
Document:
{
"user": "bob",
"message": "Hello world",
"timestamp": "2024-06-01T12:00:00Z"
}Dynamic false disables indexing of fields not explicitly mapped.
With dynamic": false, only explicitly mapped fields (user and message) are indexed; timestamp is ignored.