Message Management
User Message Search
Search all messages belonging to the current user, supporting multi-dimensional search and Chinese word segmentation
POST
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
string
required
Current user UID (restricts search to specified user’s messages)
Optional Parameters
object
Message payload, supports searching custom fields
string
Sender UID
string
Channel ID, when specified, only search messages within this channel
integer
Channel type
1- Personal channel2- Group channel
string
Search by topic
integer
Query limit, default 10
integer
Page number for pagination, default 1
integer
Message time (start), Unix timestamp
integer
Message time (end, result includes end_time), Unix timestamp
Response Fields
integer
required
Total number of messages
integer
required
Query limit
integer
required
Current page number
array
required
Message list
Status Codes
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

