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

我只是一个虾纸丫 提交于 2019-12-11 09:41:24

问题


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"?


回答1:


You have to use uppercase:

givenName:m* OR familyName:m*



回答2:


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.



来源:https://stackoverflow.com/questions/30732368/is-there-any-way-to-use-an-or-operator-in-google-directory-api-users-list-quer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!