text, keyword, or date), which analyzer processes text fields, and how fields are made available for search, sorting, and aggregations.
Dynamic mapping
By default, Elasticsearch detects field types automatically the first time a document is indexed. This is called dynamic mapping.| Field | Inferred type |
|---|---|
name | text with a .keyword sub-field |
price | float |
in_stock | boolean |
created_at | date |
Controlling dynamic mapping
You can restrict or disable dynamic mapping by setting thedynamic parameter on the index mapping.
- dynamic: false
- dynamic: strict
New fields are ignored at index time — they are not indexed and cannot be searched, but they are still stored in
_source.Explicit mapping
Define field types up front when you create an index. Explicit mappings give you full control over how fields are stored and indexed.Field types
Each field has a type that determines how its values are indexed and searched.text
Analyzed for full-text search. Values are passed through an analyzer (tokenization, lowercasing, stemming) before indexing. Use for human-readable content like email bodies or product descriptions.
keyword
Stored as-is, without analysis. Use for exact-match filtering, sorting, and aggregations — IDs, status codes, email addresses, tags.
integer / long / float / double
Numeric types for amounts and counts. Use
long for large integers, float / double for decimal values.boolean
Accepts
true and false. Also accepts "true" and "false" strings.date
Accepts ISO 8601 strings (
2024-01-15T09:00:00Z), formatted date strings, or epoch milliseconds. Store timestamps with date.ip
Stores IPv4 and IPv6 addresses. Supports CIDR range queries.
geo_point
Stores latitude/longitude coordinates. Supports geo-distance, geo-bounding-box, and geo-shape queries.
dense_vector
Stores dense float vectors for k-nearest neighbor (kNN) search. Set
dims to the vector size and choose a similarity metric (cosine, dot_product, l2_norm).text vs. keyword
Bothtext and keyword store string values, but they behave differently:
text | keyword | |
|---|---|---|
| Analysis | Analyzed (tokenized, normalized) | Not analyzed (stored as-is) |
| Full-text search | Yes | No |
| Exact match | No | Yes |
| Sorting & aggregations | No (requires fielddata) | Yes |
| Use for | Email body, product names | Status codes, IDs, tags |
text and keyword using multi-fields:
name for full-text search and name.keyword for sorting and aggregations.
dense_vector
Thedense_vector field stores numeric vectors of a fixed dimensionality, used for approximate kNN (semantic/vector) search. Indexing is enabled by default.
| Parameter | Description |
|---|---|
dims | Number of dimensions. Cannot exceed 4096. Set to the output size of your embedding model. |
index | Enable approximate kNN indexing. Defaults to true. |
similarity | Similarity metric: cosine (default), dot_product, l2_norm, max_inner_product. |
element_type | Numeric type per dimension: float (default), byte, bit, bfloat16. |
index_options.type | Index algorithm: hnsw, int8_hnsw, bbq_hnsw, flat, etc. |
Mapping parameters
These parameters control how individual fields are stored and indexed.| Parameter | Description |
|---|---|
index | Whether the field is searchable. Defaults to true. Set to false to store but not index. |
store | Store field values separately from _source. Defaults to false. |
doc_values | Store field values in column-stride format for sorting and aggregations. Defaults to true for most types. |
analyzer | Analyzer used at index and search time for text fields. Defaults to the standard analyzer. |
fields | Index the same field in multiple ways (multi-fields). |
null_value | Substitute value for explicit null values. |
Add fields to an existing mapping
UsePUT /{index}/_mapping to add new fields to an existing index. You cannot change the type of a field that already exists.
