Kibana - How to do customized sort to saved objects API

Hi,

We use:
Kibana 7.10.0
Elastic 7.10.2

We use Kibana Saved Objects Find API to get all dashboards (https://www.elastic.co/guide/en/kibana/master/saved-objects-api-find.html)

We want to get this dashboard data sorted by custom field

We found that there is sort_field field that can be sent to the API

We want to add custom field, and set it values depending on our needs

For example:

To add order field to the attributes and then we can send sort_field=order

Is this possible? How we can do that?

Thanks

According to the documentation, you should be able to send requests such as:

GET /api/saved_objects/_find?type=search&sort_field=updated_at

And you should also be able to sort based on title:

"type" fields are specific to an object type, such as fields returned in the attributes key of the response

That would look like:
GET /api/saved_objects/_find?type=index-pattern&sort_field=attributes.title

However, I was not able to get the latter example working in my local environment. If you are facing the same issue, I would recommend that you file a bug and describe your use case and results: Sign in to GitHub · GitHub

EDIT: I filed this issue: Find objects API: Unable to sort saved objects by "type" fields · Issue #94777 · elastic/kibana · GitHub

The sortField parameter is a bit magical by the fact that you can either pass a 'root' field or an 'attributes' field without prefixes

However,

  1. Only the following root fields are supported:
  • '_id'
  • '_score'
  1. ES limitations still apply to the sort fields. e.g you can't use a text field as a sort field

GET /api/saved_objects/_find?type=index-pattern&sort_field=title for example is invalid, as the title field of the index patterns is a text field

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.