[hooks] manhandle the parsed rql query, not its string representation
... and add a groupby clause to make it actually work (the selection
might well use an aggregate function, so we need to tell the backend to
group on our target entity).
Closes #5362574
addressbook
basket
blog
book
calendar
comment
company
email
file
folder
i18ncontent
keyword
link
mailinglist
person
tag
timeseries
vcsfile