- Android
- iOS
- JavaScript
- Flutter
- ReactNative
- HarmonyOS
Parameters
| Name | Type | Description | Version |
|---|---|---|---|
| conversation | Conversation | Conversation to query | 1.0.0 |
| searchContent | String | Search content | 1.0.0 |
| count | int | Number of items to retrieve. Requests over 100 return 100 items. | 1.0.0 |
| timestamp | long | Message timestamp. Pass 0 to use the current time. | 1.0.0 |
| direction | JIMConst.PullDirection | Search direction | 1.0.0 |
Code Example
List<Message> searchResults = JIM.getInstance().getMessageManager().searchMessageInConversation(conversation, "searchContent", 100, 0, JIMConst.PullDirection.OLDER);
Parameters
| Name | Type | Description | Version |
|---|---|---|---|
| searchContent | NSString | Search content | 1.0.0 |
| conversation | JConversation | Conversation to query | 1.0.0 |
| count | int | Number of items to retrieve. Requests over 100 return 100 items. | 1.0.0 |
| time | long long | Message timestamp. Pass 0 to use the current time. | 1.0.0 |
| direction | JPullDirection | Search direction | 1.0.0 |
| contentTypes | NSArray<NSString *> | Content types. Pass empty to return all types. | 1.0.0 |
Code Example
NSArray <JMessage *> *searchResults = [JIM.shared.messageManager searchMessagesWithContent:@"searchContent"
inConversation:nil
count:100
time:0
direction:JPullDirectionOlder
contentTypes:nil];
Supported Only in Electron
Local message search uses conversationId to control searches for messages in a single conversation or messages in all conversations. Pagination is supported, so it can be used for global search and in-conversation search.
Parameters
| Name | Type | Required | Description | Version |
|---|---|---|---|---|
| params | Object | Yes | Message search parameters | 1.0.0 |
| params.conversationType | Number | No | Conversation type | 1.0.0 |
| params.conversationId | String | No | Conversation ID. A value searches messages in a single conversation; an empty value searches messages in all conversations. | 1.0.0 |
| params.keywords | Array | Yes | Message search keywords. Up to five are supported; multiple keywords use an OR relationship. | 1.0.0 |
| params.senderIds | Number | No | Filter messages from specified senders | 1.0.0 |
| params.messageNames | Number | No | Filter specified message types | 1.0.0 |
| params.startTime | Number | No | Start time of the time range to filter, as a timestamp in ms | 1.0.0 |
| params.endTime | Number | No | End time of the time range to filter, as a timestamp in ms | 1.0.0 |
| params.page | Number | No | Page number for pagination. Default: 1 (the first page). | 1.0.0 |
| params.pageSize | Number | No | Number of items per page. Default: 10. | 1.0.0 |
Success Callback
| Name | Type | Description | Version |
|---|---|---|---|
| result | Object | 1.0.0 | |
| result.isFinished | Boolean | Whether all search results have been retrieved | 1.0.0 |
| result.total | Number | All-conversation search: total count of keyword matches across all conversations. Single-conversation search: count of keyword matches in that conversation. | 1.0.0 |
| result.list | Array | All-conversation search: list of messages matching keywords across all conversations, with pagination. Single-conversation search: list of messages matching keywords in that conversation, with pagination. | 1.0.0 |
result.list is a search result array. Each item is described below:
| Name | Type | Description | Version |
|---|---|---|---|
| conversationType | Number | Conversation type | 1.0.0 |
| conversationId | String | Conversation ID. For PRIVATE conversations, it is the other userId; for GROUP conversations, it is the group ID. | 1.0.0 |
| matchedCount | Array | Number of keyword matches in the current conversation | 1.0.0 |
| matchedList | Array | Message details matching keywords in the current conversation. The data contains Message objects. | 1.0.0 |
Failure Callback
| Name | Type | Description | Version |
|---|---|---|---|
| error | Object | A status code is provided when sending fails. Check error.msg directly or see status codes. | 1.0.0 |
All-Conversation Search: Code Example
let params = {
keywords: ['HelloChat'],
};
jim.searchMessages(params).then(({ isFinished, total, list }) => {
console.log(isFinished, total, list)
});
Single-Conversation Search: Code Example
let { ConversationType } = JIM;
let params = {
conversationType: ConversationType.PRIVATE,
conversationId: 'userid1',
keywords: ['HelloChat'],
};
jim.searchMessages(params).then(({ isFinished, total, list }) => {
console.log(isFinished, total, list)
});
Parameters
| Name | Type | Description | Version |
|---|---|---|---|
| params | SearchParams | Search parameters | 1.0.0 |
| callback | QryMessagesCallback | Content types. Pass empty to return all types. | 1.0.0 |
Code Example
let conver = new Conversation("userid1",1)
let params = new SearchParams()
params.conver = conver
params.keywords = "keywords"
JuggleIm.instance.getMessageManager().searchMessages(params,(code,msgs)=>{
})
Code Example
GetMessageOption option = GetMessageOption();
option.count = 20;
option.startTime = 0; // start time; 0 defaults to the current time
List<Message> messageList = await JuggleIm.instance.searchMessagesInConversation(
'searchContent',
conversation,
1, // Retrieval direction. 0: retrieve messages after the start time; 1: retrieve messages before the start time
option
);