core: z_search: fix acl check sql query.

(cherry picked from commit 562ae58a47dd389454cfee0e7c62cbfc7c028b20)