Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5c41916
[DOCS] Update first quick start with mappings examples
leemthompo Sep 25, 2024
8a6515f
Fix test?
leemthompo Sep 26, 2024
5ee1ec9
Fix tests, update verbiage
leemthompo Sep 26, 2024
119c32e
Fix heading level
leemthompo Sep 26, 2024
ce595bf
Use verbs for heading consistency
leemthompo Sep 26, 2024
6a5a17a
Remove superfluous list item
leemthompo Sep 26, 2024
f534690
I guess need some context right
leemthompo Sep 26, 2024
a2e5aeb
Fix typo
leemthompo Sep 26, 2024
31d8006
Expand intro, add prerequisites, add hints for Console usage
leemthompo Sep 27, 2024
c0eba9f
Update mappings page with combo info
leemthompo Sep 30, 2024
3a3a9a4
Updates per feedback
leemthompo Sep 30, 2024
6ca87ff
Update link text
leemthompo Sep 30, 2024
f6b77d1
Minor touchups, mainly to rerun CI
leemthompo Oct 1, 2024
8966aa2
Merge branch 'main' into qs-basics
elasticmachine Oct 1, 2024
39f8ebc
Apply suggestions from code review
leemthompo Oct 2, 2024
dbae123
Further edits per review
leemthompo Oct 2, 2024
0f09807
Reword mappings update, add clarity
leemthompo Oct 2, 2024
2d0626d
Tweak mapping updates wording
leemthompo Oct 2, 2024
43895ae
Really clarify this time
leemthompo Oct 2, 2024
536fe60
Edit update verbiage
leemthompo Oct 2, 2024
5971c2b
Typo
leemthompo Oct 2, 2024
e679e74
Apply Kathleen's suggestions
leemthompo Oct 2, 2024
11a38d0
Clarify multi-field mapping updates
leemthompo Oct 2, 2024
b20e506
Link to update mapping API
leemthompo Oct 2, 2024
88b71be
Mention some mapping params can be updated
leemthompo Oct 2, 2024
33a5619
Further clarifications
leemthompo Oct 2, 2024
015a345
Add tweaks and links
leemthompo Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions docs/reference/mapping.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,23 @@ balance resource usage and performance. Your index will be smaller, but with
slower search performance.

[discrete]
[[mapping-combine-explicit-dynamic]]
== Combine explicit and dynamic mappings
[[mapping-manage-update]]
== Managing and updating mappings

Explicit mappings should almost always be defined at index creation, because
you can't change mappings for fields that already contain data.
Explicit mappings should be defined at index creation for fields you know in advance.
You can still add _new fields_ to mappings at any time, as your data evolves.

You can _update_ mappings for existing fields under certain conditions:
Use the <<indices-put-mapping,Update mapping API>> to update an existing mapping.

. You can add new fields to an existing mapping.
. You can change the mapping for fields that don't contain any data.
. You can add new <<multi-fields,multi-fields>> for existing fields.
In most cases, you can't change mappings for fields that are already mapped.
These changes require <<docs-reindex,reindexing>>.

However, you can _update_ mappings under certain conditions:

* You can add new fields to an existing mapping at any time, explicitly or dynamically.
* You can add new <<multi-fields,multi-fields>> for existing fields.
** Documents indexed before the mapping update will not have values for the new multi-fields until they are updated or reindexed. Documents indexed after the mapping change will automatically have values for the new multi-fields.
* Some <<mapping-params,mapping parameters>> can be updated for existing fields of certain <<mapping-types,data types>>.

[discrete]
[[mapping-limit-settings]]
Expand Down
51 changes: 28 additions & 23 deletions docs/reference/quickstart/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ PUT /books
----
// TEST[skip: index already setup]

A `200` response indicates the index was created successfully.
The following response indicates the index was created successfully.

.Expand to see example response
.Example response
[%collapsible]
===============
[source,console-result]
Expand Down Expand Up @@ -96,13 +96,18 @@ If the index didn't already exist, this request would automatically create it.
[source,console]
----
POST books/_doc
{"name": "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470}
{
"name": "Snow Crash",
"author": "Neal Stephenson",
"release_date": "1992-06-01",
"page_count": 470
}
----
// TEST[continued]

The response includes metadata that {es} generates for the document, including a unique `_id` for the document within the index.

.Expand to see example response with annotations
.Example response
[%collapsible]
===============
[source,console-result]
Expand Down Expand Up @@ -159,7 +164,7 @@ POST /_bulk

You should receive a response indicating there were no errors.

.Expand to see example response
.Example response
[%collapsible]
===============
[source,console-result]
Expand Down Expand Up @@ -267,7 +272,7 @@ You should receive a response indicating there were no errors.
When using dynamic mapping, {es} automatically creates mappings for new fields by default.
The documents we've added so far have used dynamic mapping, because we didn't specify a mapping when creating the index.

Add a new document to the `books` index with a field that doesn't exist, to see how dynamic mapping works.
To see how dynamic mapping works, add a new document to the `books` index with a field that doesn't exist.

[source,console]
----
Expand All @@ -277,11 +282,12 @@ POST /books/_doc
"author": "F. Scott Fitzgerald",
"release_date": "1925-04-10",
"page_count": 180,
"new_field": "I'm a new field added dynamically" <1>
"language": "EN" <1>
}
----
// TEST[continued]
<1> This field is dynamically added to the document.
<1> The new field.

View the mapping for the `books` index. The new field `new_field` has been added to the mapping with a `text` data type.

[source,console]
Expand All @@ -290,7 +296,7 @@ GET /books/_mapping
----
// TEST[continued]

.Expand to see example response
.Example response
[%collapsible]
===============
[source,console-result]
Expand Down Expand Up @@ -344,7 +350,8 @@ GET /books/_mapping
[[getting-started-explicit-mapping]]
==== Define explicit mapping

Create an index named `my-explicit-mappings-books` with explicit mappings:
Create an index named `my-explicit-mappings-books` with explicit mappings.
Pass each field's properties as a JSON object. This object should contain the field type and any additional <<mapping-params,mapping parameters>>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 do we want a link to available types here?


[source,console]
----
Expand All @@ -353,22 +360,19 @@ PUT /my-explicit-mappings-books
"mappings": {
"dynamic": false, <1>
"properties": { <2>
"name": { "type": "text" }, <3>
"name": { "type": "text" },
"author": { "type": "text" },
"release_date": { "type": "date", "format": "yyyy-MM-dd" }, <4>
"page_count": { "type": "integer" } <5>
"release_date": { "type": "date", "format": "yyyy-MM-dd" },
"page_count": { "type": "integer" }
}
}
}
----
// TEST[continued]
<1> Disables dynamic mapping for the index. Documents containing fields not defined in the mapping will be rejected.
<2> The `properties` object defines the fields and their data types for documents in this index.
<3> Defines the "name" field as type "text", suitable for full-text search on book titles.
<4> Specifies the "release_date" field as a "date" type with the specific format `yyyy-MM-dd`.
<5> Sets the "page_count" field as an "integer" type for storing the number of pages.

.Expand to see example response
.Example response
[%collapsible]
===============
[source,console-result]
Expand All @@ -387,8 +391,11 @@ PUT /my-explicit-mappings-books
==== Combine dynamic and explicit mappings

Explicit mappings are defined at index creation, and documents must conform to these mappings.
You can also use the <<indices-put-mapping,Update mapping API>>.
When an index has the `dynamic` flag set to `true`, you can add new fields to documents without updating the mapping.
This allows you to <<mapping-combine-explicit-dynamic,combine explicit and dynamic mappings>>.

This allows you to combine explicit and dynamic mappings.
Learn more about <<mapping-manage-update,managing and updating mappings>>.

[discrete]
[[getting-started-search-data]]
Expand All @@ -409,7 +416,7 @@ GET books/_search
----
// TEST[continued]

.Expand to see (truncated) example response with annotations
.Example response
[%collapsible]
===============
[source,console-result]
Expand Down Expand Up @@ -481,7 +488,7 @@ GET books/_search
----
// TEST[continued]

.Expand to see example response with annotations
.Example response
[%collapsible]
===============
[source,console-result]
Expand Down Expand Up @@ -526,7 +533,7 @@ GET books/_search
=== Step 5: Delete your indices (optional)

When following along with examples, you might want to delete an index to start from scratch.
You can delete indices using the <<indices-delete-index,`DELETE` index API>>.
You can delete indices using the <<indices-delete-index,Delete index API>>.

For example, run the following command to delete the indices created in this tutorial:

Expand All @@ -541,5 +548,3 @@ DELETE /my-explicit-mappings-books
====
Deleting an index permanently deletes its documents, shards, and metadata.
====