Overview
Search all messages belonging to the current user, supporting multi-dimensional search and Chinese word segmentation functionality.- Requires WuKongIM v2.1.3-20250210 or above
- Requires installation of
wk.plugin.searchplugin - Plugin usage documentation: Plugin Development Guide
Request Body
Required Parameters
Current user UID (restricts search to specified user’s messages)
Optional Parameters
Message payload, supports searching custom fields
Sender UID
Channel ID, when specified, only search messages within this channel
Channel type
1- Personal channel2- Group channel
Search by topic
Query limit, default 10
Page number for pagination, default 1
Message time (start), Unix timestamp
Message time (end, result includes end_time), Unix timestamp
Keyword fields that need highlighting
Field name, e.g., “payload.content”
Response Fields
Total number of messages
Query limit
Current page number
Message list
Status Codes
| Status Code | Description |
|---|---|
| 200 | Search successful |
| 400 | Request parameter error |
| 403 | No search permission |
| 500 | Internal server error |
Search Features
Chinese Word Segmentation
Supports Chinese word segmentation, intelligently recognizing Chinese vocabulary for search. Examples:- Searching “Beijing University” can match messages containing “Beijing” or “University”
- Supports both fuzzy matching and exact matching
Multi-dimensional Search
Supports combined search across multiple dimensions:- Content Search: Search message content through
payload.content - Type Search: Limit message types through
payload_types - User Search: Search specific user’s messages through
from_uid - Channel Search: Search specific channel’s messages through
channel_id - Time Search: Limit time range through
start_timeandend_time - Topic Search: Search specific topic messages through
topic
Highlighting
Through thehighlights parameter, you can specify fields that need highlighting. Matching keywords in search results will be surrounded by <mark> tags.
Example:
Use Cases
Chat History Search
- Keyword Search: Users search for keywords in chat history
- User Messages: Search messages sent by specific users
- Group Messages: Search messages within specific groups
Content Management
- Message Moderation: Search messages containing specific content
- Data Analysis: Analyze user message content and behavior
- Compliance Check: Check for sensitive content
Advanced Search Examples
Search by Time Range:Best Practices
- Pagination: Use appropriate page size to avoid performance issues
- Time Limits: Set reasonable time ranges for better performance
- Keyword Optimization: Use specific keywords for more accurate results
- Result Caching: Cache search results for frequently used queries
- Permission Check: Ensure users can only search their own messages
- Rate Limiting: Implement rate limiting to prevent search abuse

