elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.71k stars 8.13k forks source link

[Cases] Provide suggestions when searching for users #142310

Open cnasikas opened 1 year ago

cnasikas commented 1 year ago

In 8.5, we added the ability to assign users to a case. Users can open a popover and search for potential assignees. The popover does not offer any suggestions. We would like to offer the ability to provide suggestions to the users. Suggestions can include:

To search for users we use the suggest API provided by the security team. One way to provide suggestions is to use the hint parameter which currently is not exposed by the API in Kibana. The hint will contain all the uids of the suggested users. Then we can pass the hint results as defaultOptions in the UserProfilesPopover component. Another solution would be to not use the hint, prefetch the user profiles of the suggested users (using the bulkGet API), and pass them to UserProfilesPopover. If we go with hint we need to ensure that a search result with an empty string (this request is being made when the user opens the popover to search) respects the hint and returns the suggested users. A third solution is to use a combination of both solutions.

elasticmachine commented 1 year ago

Pinging @elastic/response-ops-cases (Feature:Cases)

elasticmachine commented 1 year ago

Pinging @elastic/response-ops (Team:ResponseOps)

azasypkin commented 1 year ago

We would like to offer the ability to provide suggestions to the users. Suggestions can include:

I think this is the ideal use case for the hint.uids parameter exposed via Elasticsearch Suggest User Profiles API, I filed https://github.com/elastic/kibana/issues/142327 to re-expose this parameter from the Kibana API counterpart.

Another solution would be to not use the hint, prefetch the user profiles of the suggested users (using the bulkGet API), and pass them to UserProfilesPopover

That could work, but I'd still prefer suggest API with hints as it can boost returned results based on the last login time and, potentially, other factors in the future that we can find useful.

A third solution is to use a combination of both solutions.

It's probably what you'll end up with in the end anyway assuming you want to always display the current user as the first suggestion. The hint.uids doesn't have a notion of the current user so it will respect only the last login time while scoring the results (with the empty name), and it might happen so that the other users logged in after the current one and hence will be ranked higher:

const suggestions = [
  await userProfiles.getCurrent(...),
  ...(await userProfiles.suggest({ name: '', hints: { uids: ['u_xxx_0', 'u_yyy_0'] } }));
];