Update data stream mappings
Generally available
This API can be used to override mappings on specific data streams. These overrides will take precedence over what is specified in the template that the data stream matches. The mapping change is only applied to new write indices that are created during rollover after this API is called. No indices are changed by this API.
Required authorization
- Index privileges:
manage
Query parameters
-
If
true
, the request does not actually change the mappings on any data streams. Instead, it simulates changing the settings and reports back to the user what would have happened had these settings actually been applied. -
The period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.
Values are
-1
or0
. -
The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
Values are
-1
or0
.
PUT /_data_stream/my-data-stream/_mappings
{
"properties":{
"field1":{
"type":"ip"
},
"field3":{
"type":"text"
}
}
}
resp = client.indices.put_data_stream_mappings(
name="my-data-stream",
mappings={
"properties": {
"field1": {
"type": "ip"
},
"field3": {
"type": "text"
}
}
},
)
const response = await client.indices.putDataStreamMappings({
name: "my-data-stream",
mappings: {
properties: {
field1: {
type: "ip",
},
field3: {
type: "text",
},
},
},
});
response = client.indices.put_data_stream_mappings(
name: "my-data-stream",
body: {
"properties": {
"field1": {
"type": "ip"
},
"field3": {
"type": "text"
}
}
}
)
$resp = $client->indices()->putDataStreamMappings([
"name" => "my-data-stream",
"body" => [
"properties" => [
"field1" => [
"type" => "ip",
],
"field3" => [
"type" => "text",
],
],
],
]);
curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"properties":{"field1":{"type":"ip"},"field3":{"type":"text"}}}' "$ELASTICSEARCH_URL/_data_stream/my-data-stream/_mappings"
{
"properties":{
"field1":{
"type":"ip"
},
"field3":{
"type":"text"
}
}
}
{
"data_streams": [
{
"name": "my-data-stream",
"applied_to_data_stream": true,
"mappings": {
"properties": {
"field1": {
"type": "ip"
},
"field3": {
"type": "text"
}
}
},
"effective_mappings": {
"properties": {
"field1": {
"type": "ip"
},
"field3": {
"type": "text"
}
}
}
}
]
}
{
"data_streams": [
{
"name": "my-data-stream",
"applied_to_data_stream": false,
"error": "Failed to parse mapping: The mapper type [txt] declared on field [field1] does not exist. It might have been created within a future version or requires a plugin to be installed. Check the documentation.",
"mappings": {
"_doc": {}
},
"effective_mappings": {
"_doc": {}
}
}
]
}