nearform / udaru

Open source Access Manager for node.js
https://nearform.github.io/udaru
MIT License
124 stars 19 forks source link

centralised search #548

Open cianfoley-nearform opened 6 years ago

cianfoley-nearform commented 6 years ago

I think it would be a good idea to have a centralised search endpoint as it would be nice to provide a consistent search across the entire db across all entities...

Here's a suggestion as to how it might be defined

/authorization/search/{teamId*}
?query=xyz
&searchtype=fulltext|startswith|exact|fuzzy
&entitytype=users|teams|policies|all
&field=id|name|description|meta.field
&recursive=true|false
&order=asc|desc
&limit=X
&page=Y 

If the teamId* route param is empty, search would look through the entire db

If a teamId(s) is specified here it could be referenced by path (which we return on teams endpoints) e.g.

/authorization/search/team1/team1-1

With no params set, it might return the teams entities (as per the team call) and so we could traverse the system with nice RESTful routing.

If search params are specified then it would search for children of the team specified only i.e. look for sub teams, users and policies, depending on flags

E.g.

/authorization/search/team1/team1-1
?query=b
&searchtype=startswith
&entitytype=user
&field=name
&recursive=false
&order=asc

would would return all users in team1-1 with names starting with the letter b ordered alphabetically, which would be useful for an autocomplete component on a UI