Skip to main content
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.search plugin
  • 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
array
Message type search
integer
Message type value
string
Sender UID
string
Channel ID, when specified, only search messages within this channel
integer
Channel type
  • 1 - Personal channel
  • 2 - 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
array
Keyword fields that need highlighting
string
Field name, e.g., “payload.content”

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
Supports combined search across multiple dimensions:
  1. Content Search: Search message content through payload.content
  2. Type Search: Limit message types through payload_types
  3. User Search: Search specific user’s messages through from_uid
  4. Channel Search: Search specific channel’s messages through channel_id
  5. Time Search: Limit time range through start_time and end_time
  6. Topic Search: Search specific topic messages through topic

Highlighting

Through the highlights parameter, you can specify fields that need highlighting. Matching keywords in search results will be surrounded by <mark> tags. Example:
Return result:

Use Cases

  • 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:
Search by Message Type:
Search with Multiple Criteria:

Best Practices

  1. Pagination: Use appropriate page size to avoid performance issues
  2. Time Limits: Set reasonable time ranges for better performance
  3. Keyword Optimization: Use specific keywords for more accurate results
  4. Result Caching: Cache search results for frequently used queries
  5. Permission Check: Ensure users can only search their own messages
  6. Rate Limiting: Implement rate limiting to prevent search abuse