Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
Method: spaces.search
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
返回 Google Workspace 组织中的空间列表。如需查看示例,请参阅搜索和管理聊天室。
当 useAdminAccess 设置为 false 时,结果仅限于调用用户已加入的空间。如需使用管理员权限进行搜索,请将 useAdminAccess 设置为 true。在开发者预览版中,您可以将 useAdminAccess 设置为 false。
支持以下类型的身份验证:
使用以下授权范围之一进行用户身份验证:
https://www.googleapis.com/auth/chat.spaces.readonly
https://www.googleapis.com/auth/chat.spaces
具有管理员权限的用户身份验证和以下某个授权范围:
https://www.googleapis.com/auth/chat.admin.spaces.readonly
https://www.googleapis.com/auth/chat.admin.spaces
HTTP 请求
GET https://chat.googleapis.com/v1/spaces:search
网址采用 gRPC 转码语法。
查询参数
| 参数 |
useAdminAccess |
boolean
如果值为 true,则该方法会使用用户的 Google Workspace 管理员权限运行。 调用用户必须是拥有“管理聊天和聊天室对话”权限的 Google Workspace 管理员。 需要 chat.admin.spaces.readonly 或 chat.admin.spaces OAuth 2.0 范围。 在开发者预览版中,可将 useAdminAccess 设置为 false。
|
pageSize |
integer
要返回的空间数量上限。服务返回的值可能小于此值。 如果未指定,则系统最多返回 100 个空间。 最大值为 1000。如果您使用的值超过 1,000,系统会自动将其更改为 1,000。
|
pageToken |
string
从上一次搜索空间调用中收到的令牌。提供此参数可检索后续页面。 进行分页时,提供的所有其他参数应与提供页面令牌的调用相一致。向其他参数传递不同的值可能会导致意外结果。
|
query |
string
必需。搜索查询。 当 useAdminAccess 设置为 true 时,您可以使用以下参数进行搜索:
createTime
customer
displayName
externalUserAllowed
lastActiveTime
spaceHistoryState
spaceType
当 useAdminAccess 设置为 false 时:
displayName
externalUserAllowed
createTime 和 lastActiveTime 接受 RFC-3339 格式的时间戳,支持的比较运算符包括:=、<、>、<=、>=。
当 useAdminAccess 设置为 true 时,必须提供 customer,用于指明要从哪个客户处提取聊天室。customers/my_customer 是唯一支持的值。 displayName 仅接受 HAS (:) 运算符。要匹配的文本首先会被词元化为词元,然后每个词元都会以不区分大小写的方式独立进行前缀匹配,作为displayName中任意位置的子字符串。例如,Fun Eve 与 Fun event 或 The
evening was fun 匹配,但不与 notFun event 或 even 匹配。当 useAdminAccess 设置为 false 时,需要提供 displayName 才能检索有意义的结果。否则,默认行为是返回空响应。
externalUserAllowed 接受 true 或 false。
spaceHistoryState 仅接受 space 资源的 historyState 字段中的值。
当 useAdminAccess 设置为 true 时,spaceType 是必需的,并且唯一有效的值是 SPACE。 在不同字段之间,仅支持 AND 运算符。有效示例为 spaceType = "SPACE" AND displayName:"Hello",无效示例为 spaceType = "SPACE" OR displayName:"Hello"。 在同一字段中,spaceType 不支持 AND 或 OR 运算符。displayName、“spaceHistoryState”和“externalUserAllowed”仅支持 OR 运算符。lastActiveTime 和 createTime 同时支持 AND 和 OR 运算符。AND 只能用于表示时间段,例如 lastActiveTime
< "2022-01-01T00:00:00+00:00" AND lastActiveTime >
"2023-01-01T00:00:00+00:00"。 当 useAdminAccess 设置为 true 时,以下示例查询有效:
customer = "customers/my_customer" AND spaceType = "SPACE"
customer = "customers/my_customer" AND spaceType = "SPACE" AND
displayName:"Hello World"
customer = "customers/my_customer" AND spaceType = "SPACE" AND
(lastActiveTime < "2020-01-01T00:00:00+00:00" OR lastActiveTime >
"2022-01-01T00:00:00+00:00")
customer = "customers/my_customer" AND spaceType = "SPACE" AND
(displayName:"Hello World" OR displayName:"Fun event") AND
(lastActiveTime > "2020-01-01T00:00:00+00:00" AND lastActiveTime <
"2022-01-01T00:00:00+00:00")
customer = "customers/my_customer" AND spaceType = "SPACE" AND
(createTime > "2019-01-01T00:00:00+00:00" AND createTime <
"2020-01-01T00:00:00+00:00") AND (externalUserAllowed = "true") AND
(spaceHistoryState = "HISTORY_ON" OR spaceHistoryState = "HISTORY_OFF")
当 useAdminAccess 设置为 false 时,以下示例查询有效:
displayName:"Hello World"
(displayName:"Hello" OR displayName:"Fun")
(externalUserAllowed = "true") // Returns an empty response.
(externalUserAllowed = "true" AND displayName:"Hello")
|
orderBy |
string
可选。聊天室列表的排序方式。 支持的排序依据属性包括:
membershipCount.joined_direct_human_user_count - 表示直接加入聊天室的人类用户数量。
lastActiveTime - 表示上次将符合条件的商品添加到相应聊天室的任何主题的时间。
createTime - 表示聊天室的创建时间。
当 useAdminAccess 为 false 时,仅支持 createTime 和 relevance 作为排序依据。在非管理员搜索中,这些字段仅支持 DESC。 有效的排序操作值包括:
当 useAdminAccess 设置为 true 时,支持的语法如下:
membershipCount.joined_direct_human_user_count DESC
membershipCount.joined_direct_human_user_count ASC
lastActiveTime DESC
lastActiveTime ASC
createTime DESC
createTime ASC
当 useAdminAccess 设置为 false 时:
createTime DESC
relevance DESC
|
响应正文
包含与搜索聊天室请求相对应的聊天室列表的响应。
如果成功,响应正文将包含结构如下的数据:
| JSON 表示法 |
{
"spaces": [
{
object (Space)
}
],
"nextPageToken": string,
"totalSize": integer,
"results": [
{
object (SearchSpaceResult)
}
]
} |
| 字段 |
spaces[] (deprecated) |
object (Space)
已弃用:请改用新的 results 字段。所请求空间的页面。只有当 useAdminAccess 设置为 true 时,系统才会填充此字段,并且此字段已弃用,取而代之的是新的 results 字段。
|
nextPageToken |
string
可用于检索下一页的令牌。如果此字段为空,则不存在后续页面。
|
totalSize |
integer
与查询匹配的所有空间的总数(包括所有页面)。如果结果超过 10,000 个空格,则此值为估计值。
|
results[] |
object (SearchSpaceResult)
仅限输出。 与查询匹配的搜索结果列表。
|
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/chat.spaces
https://www.googleapis.com/auth/chat.spaces.readonly
https://www.googleapis.com/auth/chat.admin.spaces
https://www.googleapis.com/auth/chat.admin.spaces.readonly
如需了解详情,请参阅授权指南。
SearchSpaceResult
| JSON 表示法 |
{
"space": {
object (Space)
}
} |
| 字段 |
space |
object (Space)
仅限输出。匹配的聊天室。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-06-17。
[null,null,["最后更新时间 (UTC):2026-06-17。"],[],["To search for Google Workspace spaces, send a `GET` request to `https://chat.googleapis.com/v1/spaces:search`, ensuring admin privileges and setting `useAdminAccess` to `true`. Define the search using query parameters, including a required `query` to filter spaces (by `customer`, `displayName`, etc.), optional `pageSize` and `pageToken` for pagination, and optional `orderBy` for sorting. You must have one of the authorization scopes: `chat.admin.spaces` or `chat.admin.spaces.readonly`. The response will list spaces matching the query.\n"]]