Skip to content

Adding specification for the new data stream mappings API #4751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 9, 2025

Conversation

masseyke
Copy link
Member

@masseyke masseyke commented Jul 1, 2025

This adds specifications for the new data stream mappings APIs.

@masseyke masseyke added specification compiler skip-backport This pull request should not be backported labels Jul 1, 2025
Copy link
Contributor

github-actions bot commented Jul 1, 2025

Following you can find the validation changes against the target branch for the APIs.

API Status Request Response
indices.get_data_stream 🔴 119/119 17/119 → 75/119
indices.get_data_stream_mappings 🟠 → 🟢 Missing type → 3/3 Missing type → 3/3
indices.put_data_stream_mappings 🟠 → 🟢 Missing type → 3/3 Missing type → 3/3

You can validate these APIs yourself by using the make validate target.

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

The API themselves look great, thank you! I do have questions about examples, but am not sure of the answers.

Comment on lines 2 to 24
alternatives:
- language: Python
code: |-
resp = client.indices.get_data_stream_mappings(
name="my-data-stream",
)
- language: JavaScript
code: |-
const response = await client.indices.getDataStreamSettings({
name: "my-data-stream",
});
- language: Ruby
code: |-
response = client.indices.get_data_stream_mappings(
name: "my-data-stream"
)
- language: PHP
code: |-
$resp = $client->indices()->getDataStreamSettings([
"name" => "my-data-stream",
]);
- language: curl
code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_data_stream/my-data-stream/_mappings"'
Copy link
Member

Choose a reason for hiding this comment

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

All the alternatives are generated. However a summary (and description if needed) would help.

Comment on lines 17 to 82
alternatives:
- language: Python
code: |-
resp = client.indices.put_data_stream_mappings(
name="my-data-stream",
mappings={
"properties":{
"field1":{
"type":"ip"
},
"field3":{
"type":"text"
}
}
},
)
- language: JavaScript
code: |-
const response = await client.indices.putDataStreamSettings({
name: "my-data-stream",
mappings: {
"properties":{
"field1":{
"type":"ip"
},
"field3":{
"type":"text"
}
}
},
});
- language: Ruby
code: |-
response = client.indices.put_data_stream_mappings(
name: "my-data-stream",
body: {
"properties":{
"field1":{
"type":"ip"
},
"field3":{
"type":"text"
}
}
}
)
- language: PHP
code: |-
$resp = $client->indices()->putDataStreamSettings([
"name" => "my-data-stream",
"body" => [
"properties" => [
"field1" => [
"type" => "ip"
],
"field3" => [
"type" => "text"
]
]
],
]);
- language: curl
code:
'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d
''{"index.lifecycle.name":"new-test-policy","index.number_of_shards":11}''
"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_mappings"'
Copy link
Member

Choose a reason for hiding this comment

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

Sorry that you took the time to do this, but it's generated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I had wondered if that was the case, but didn't see a way to generate them.

Comment on lines 5 to 6
# type: response
# response_code: 200
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be uncommented. Not too familiar with examples to be honest. (I do appreciate that you worked on them!)

Suggested change
# type: response
# response_code: 200
type: response
response_code: 200

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm I copied all of these from the examples I had done for the simulate ingest API. Those also have this commented out. I probably need to fix those as well. (And I had probably copied those from somewhere else that also needs to be fixed.)

* 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.
* @rest_spec_name indices.put_data_stream_mappings
* @availability stack stability=stable visibility=public
Copy link
Contributor

Choose a reason for hiding this comment

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

I presume this is true here too:

Suggested change
* @availability stack stability=stable visibility=public
* @availability stack since=9.1.0 stability=stable visibility=public

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, 9.2.0. But I'll add that. Thanks.

@masseyke masseyke requested review from pquentin and lcawl July 8, 2025 13:27
@lcawl lcawl requested a review from a team July 8, 2025 23:13
Comment on lines 42 to 45
/**
* The mappings that are specfic to this data stream that will override any mappings from the matching index template.
*/
mappings: TypeMapping
Copy link
Member

@pquentin pquentin Jul 9, 2025

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh you are right. I'm not sure that was the wisest decision on my part, but it is optional. I've updated the spec.

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

@pquentin pquentin merged commit dc3690c into main Jul 9, 2025
8 checks passed
@pquentin pquentin deleted the data-stream-mappings branch July 9, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler skip-backport This pull request should not be backported specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants