Search code examples
google-app-enginegoogle-admin-sdkgoogle-directory-api

Is there any way to use an "or" operator in Google Directory API users.list query?


I want to build a search query for Google domain users using users.list Google Directory API. I tried to build a query according docs, which will select all users with givenName or familyName starts e.g. on letter "m".
I wrote the query: givenName:m* or familyName:m*, but it doesn't work.
Only givenName:m* familyName:m* works but it inserts "and" operator between clauses.
In docs stays:

Multiple clauses are separated by whitespace and are implicitly joined by an "and" operator.

Can I only write a query with the implicit "and" operator? Is there any way how to write it using "or"?


Solution

  • After some time experimenting with the API I have found out that I really don't need {{PREFIX}}* or some operators to accomplish my goal.

    If you want to search all the users whose given or family name starts e.g. on letter "m", just put a single m (without field name e.g. "givenName:") into the query parameter. It seems that API implicitly searches in all domain users' givenName and familyName fields. It also searches in a substring (before "@") of all email fields (e.g. martin@example.com).

    If you put word "example" in the query, it'll gives you all users with email field something@example.com.

    It is possible that if you put only some string without any specified fields, the API may also searches in any other field, but I didn't find in which.

    I don't know if this is a bug or a feature, but I know it partially gives an answer to my question.