chat.searchCloudGroups(options);
Name | Type | Description |
keywordList | Array | required Keyword list, support up to 5 keywords. |
keywordListMatchType | String | undefined | Keyword List Matching Type: or: relational search ("or" relationship) (default) and: relational search ("and" relationship) |
groupTypeList | Array | undefined | If not provided, the default search is for all types of groups (live groups not supported ( TencentCloudChat.TYPES.GRP_AVCHATROOM )).Group Types Indicate: TencentCloudChat.TYPES.GRP_WORK friends work groupTencentCloudChat.TYPES.GRP_PUBLIC stranger social groupTencentCloudChat.TYPES.GRP_MEETING temporary meeting groupTencentCloudChat.TYPES.GRP_COMMUNITY community |
cursor | String | undefined | The starting position for each search of cloud groups. Do not pass in cursor for the first search. For continuing the search, fill in the value of cursor returned by the last call to the searchCloudGroups API. |
count | Number | undefined | The number of results for each search of cloud groups. The default value is 20, and the maximum value is 100. |
Promise
Name | Type | Description |
totalCount | Number | The total number of groups meeting the search criteria. |
searchResultList | Array | The list of group profiles Group meeting the search criteria includes only group ID groupID , group avatar avatar , group name name , group type type , current member count memberCount , group introduction introduction , and group owner ID ownerID , which can meet the rendering needs of the search results list. For detailed group information, refer to: getGroupProfile. |
cursor | String | The cursor needed for calling the search API to continue pulling. |
// List of specified keywords and group types to search// - Search for groups where 'test' or 'user' appears in the user list, and the group type is 'stranger social group (TencentCloudChat.TYPES.GRP_PUBLIC)' or 'friends work group (TencentCloudChat.TYPES.GRP_WORK)'let promise = chat.searchCloudGroups({keywordList: ['test', 'user'],groupTypeList: [TencentCloudChat.TYPES.GRP_PUBLIC, TencentCloudChat.TYPES.GRP_WORK],});promise.then(function(imResponse) {// Search group succeededconst { totalCount, cursor, searchResultList } = imResponse.data;console.log(totalCount); // Total number of groups meeting the search criteriaconsole.log(cursor); // Starting position for the next cloud search, if not present, indicates search results are fully retrievedconsole.log(searchResultList); // Groups meeting search criteria, return paginated grouping results, maximum return of 100 per page, based on the input countfor (let i = 0; i < searchResultList.length; i++) {const groupItem = searchResultList[i];const { groupID, name, type, avatar, memberCount, introduction, ownerID } = groupItem;console.log(groupID); // Group IDconsole.log(name); // Group nameconsole.log(type); // Group typeconsole.log(avatar); // Group avatarconsole.log(memberCount); // Current member countconsole.log(introduction); // Group introductionconsole.log(ownerID); // Group owner userid}}).catch(function(imError) {console.error(imError); // search user failed});
Was this page helpful?