chat.searchCloudGroups(options);
Name | Type | Description |
keywordList | Array | required 关键字列表,最多支持 5 个。 |
keywordListMatchType | String | undefined | 关键字列表匹配类型: or:“或”关系搜索(默认) and:“与”关系搜索 |
groupTypeList | Array | undefined | 不传入时默认搜索所有类型群组(不支持直播群( TencentCloudChat.TYPES.GRP_AVCHATROOM )类型的搜索)。群类型表示: TencentCloudChat.TYPES.GRP_WORK 好友工作群TencentCloudChat.TYPES.GRP_PUBLIC 陌生人社交群TencentCloudChat.TYPES.GRP_MEETING 临时会议群TencentCloudChat.TYPES.GRP_COMMUNITY 社群 |
cursor | String | undefined | 每次搜索云端群组的起始位置。第一次搜索时不要传入 cursor ,继续搜索时填入上次调用 searchCloudGroups 接口返回的 cursor 的值。 |
count | Number | undefined | 每次搜索云端群组结果的数量,默认值为 20, 最大值为100。 |
Promise
Name | Type | Description |
totalCount | Number | 满足搜索条件的群组总数。 |
searchResultList | Array | 满足搜索条件的群组资料 Group 列表,仅包括群组ID groupID 、群组头像 avatar 、群组名称 name 、群组类型 type 、群组当前成员数量 memberCount 、群组简介 introduction 、群主ID ownerID 等,能够满足群搜索结果列表的渲染需求,若要查询详细群资料,可参考:getGroupProfile。 |
cursor | String | 调用搜索接口续拉时需要填的游标。 |
// 搜索指定关键字列表和群组类型// - 搜索用户里出现 'test' 或 'user' ,且群组类型为 '陌生人社交群(TencentCloudChat.TYPES.GRP_PUBLIC)' 或 '好友工作群(TencentCloudChat.TYPES.GRP_WORK)' 的群组let promise = chat.searchCloudGroups({keywordList: ['test', 'user'],groupTypeList: [TencentCloudChat.TYPES.GRP_PUBLIC, TencentCloudChat.TYPES.GRP_WORK],});promise.then(function(imResponse) {// 搜索群组成功const { totalCount, cursor, searchResultList } = imResponse.data;console.log(totalCount); // 满足搜索条件的群组总数量console.log(cursor); // 下一次云端搜索的起始位置, 如果没有表示搜索结果拉取完成console.log(searchResultList); // 满足搜索条件的群组列表,分页返回分组结果,每页最大返回 100 条,根据传入 count 设定for (let i = 0; i < searchResultList.length; i++) {const groupItem = searchResultList[i];const { groupID, name, type, avatar, memberCount, introduction, ownerID } = groupItem;console.log(groupID); // 群组 IDconsole.log(name); // 群组名称console.log(type); // 群组类型console.log(avatar); // 群组头像console.log(memberCount); // 群组当前成员数量console.log(introduction); // 群简介console.log(ownerID); // 群主 userID}}).catch(function(imError) {console.error(imError); // 搜索用户失败});
本页内容是否解决了您的问题?