kibana/docs/api/data-views/update-fields.asciidoc
Matthias Wilhelm 40c75ed1a2
[Data Views] Fix data view field update paths in documentation (#158900)
## Summary

This PR fixes the documentation for the "update data view fields" API which used an incorrect route in the provided examples (data-view instead of data_view)
2023-06-02 16:02:54 +02:00

153 lines
3.3 KiB
Text

[[data-views-fields-api-update]]
=== Update data view fields API
++++
<titleabbrev>Update data view fields metadata</titleabbrev>
++++
experimental[] Update fields presentation metadata, such as `count`,
`customLabel`, and `format`. You can update multiple fields in one request. Updates
are merged with persisted metadata. To remove existing metadata, specify `null` as the value.
[[data-views-fields-api-update-request]]
==== Request
`POST <kibana host>:<port>/api/data_views/data_view/<id>/fields`
`POST <kibana host>:<port>/s/<space_id>/api/data_views/data_view/<id>/fields`
[[data-views-fields-api-update-path-params]]
==== Path parameters
`space_id`::
(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used.
`id`::
(Required, string) The ID of the data view fields you want to update.
[[data-views-fields-api-update-request-body]]
==== Request body
`fields`::
(Required, object) the field object
[[data-views-fields-api-update-errors-codes]]
==== Response code
`200`::
Indicates a successful call.
[[data-views-fields-api-update-example]]
==== Examples
Set popularity `count` for field `foo`:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-view/fields
{
"fields": {
"foo": {
"count": 123
}
}
}
--------------------------------------------------
// KIBANA
Change a simple field format:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-view/fields
{
"fields": {
"foo": {
"format": {
"id": "bytes"
}
}
}
}
--------------------------------------------------
// KIBANA
Change a complex field format:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-view/fields
{
"fields": {
"foo": {
"format": {
"id": "static_lookup",
"params": {
"lookupEntries": [
{
"key": "1",
"value": "100"
},
{
"key": "2",
"value": "200"
}
],
"unknownKeyValue": "5000"
}
}
}
}
}
--------------------------------------------------
// KIBANA
Update multiple metadata fields in one request:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-view/fields
{
"fields": {
"foo": {
"count": 123,
"customLabel": "Foo"
},
"bar": {
"customLabel": "Bar"
}
}
}
--------------------------------------------------
// KIBANA
Use `null` value to delete metadata:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-pattern/fields
{
"fields": {
"foo": {
"customLabel": null
}
}
}
--------------------------------------------------
// KIBANA
The endpoint returns the updated data view object:
[source,sh]
--------------------------------------------------
{
"data_view": {
}
}
--------------------------------------------------