curl -X POST "http://localhost:5001/plugins/wk.plugin.search/usersearch" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"payload": {
"content": "Beijing"
},
"payload_types": [1, 2],
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": ["payload.content"]
}'
const searchParams = {
uid: "user123",
payload: {
content: "Beijing"
},
payload_types: [1, 2],
channel_type: 2,
limit: 10,
page: 1,
highlights: ["payload.content"]
};
const response = await fetch('http://localhost:5001/plugins/wk.plugin.search/usersearch', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(searchParams)
});
const data = await response.json();
console.log(data);
import requests
search_params = {
"uid": "user123",
"payload": {
"content": "Beijing"
},
"payload_types": [1, 2],
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": ["payload.content"]
}
response = requests.post(
'http://localhost:5001/plugins/wk.plugin.search/usersearch',
json=search_params
)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
searchParams := map[string]interface{}{
"uid": "user123",
"payload": map[string]interface{}{
"content": "Beijing",
},
"payload_types": []int{1, 2},
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": []string{"payload.content"},
}
jsonData, _ := json.Marshal(searchParams)
resp, err := http.Post(
"http://localhost:5001/plugins/wk.plugin.search/usersearch",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"total": 25,
"limit": 10,
"page": 1,
"messages": [
{
"message_id": 1234,
"message_idstr": "1234",
"message_seq": 1,
"client_msg_no": "djzdfdfdf",
"from_uid": "u1",
"channel_id": "g1",
"channel_type": 2,
"payload": {
"type": 1,
"content": "Are you from <mark>Beijing</mark> University?"
},
"topic": "",
"timestamp": 762834
},
{
"message_id": 1235,
"message_idstr": "1235",
"message_seq": 2,
"client_msg_no": "djzdfdfde",
"from_uid": "u2",
"channel_id": "g1",
"channel_type": 2,
"payload": {
"type": 1,
"content": "I work in <mark>Beijing</mark>"
},
"topic": "",
"timestamp": 762835
}
]
}
Message Management
User Message Search
Search all messages belonging to the current user, supporting multi-dimensional search and Chinese word segmentation
POST
/
plugins
/
wk.plugin.search
/
usersearch
curl -X POST "http://localhost:5001/plugins/wk.plugin.search/usersearch" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"payload": {
"content": "Beijing"
},
"payload_types": [1, 2],
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": ["payload.content"]
}'
const searchParams = {
uid: "user123",
payload: {
content: "Beijing"
},
payload_types: [1, 2],
channel_type: 2,
limit: 10,
page: 1,
highlights: ["payload.content"]
};
const response = await fetch('http://localhost:5001/plugins/wk.plugin.search/usersearch', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(searchParams)
});
const data = await response.json();
console.log(data);
import requests
search_params = {
"uid": "user123",
"payload": {
"content": "Beijing"
},
"payload_types": [1, 2],
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": ["payload.content"]
}
response = requests.post(
'http://localhost:5001/plugins/wk.plugin.search/usersearch',
json=search_params
)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
searchParams := map[string]interface{}{
"uid": "user123",
"payload": map[string]interface{}{
"content": "Beijing",
},
"payload_types": []int{1, 2},
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": []string{"payload.content"},
}
jsonData, _ := json.Marshal(searchParams)
resp, err := http.Post(
"http://localhost:5001/plugins/wk.plugin.search/usersearch",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"total": 25,
"limit": 10,
"page": 1,
"messages": [
{
"message_id": 1234,
"message_idstr": "1234",
"message_seq": 1,
"client_msg_no": "djzdfdfdf",
"from_uid": "u1",
"channel_id": "g1",
"channel_type": 2,
"payload": {
"type": 1,
"content": "Are you from <mark>Beijing</mark> University?"
},
"topic": "",
"timestamp": 762834
},
{
"message_id": 1235,
"message_idstr": "1235",
"message_seq": 2,
"client_msg_no": "djzdfdfde",
"from_uid": "u2",
"channel_id": "g1",
"channel_type": 2,
"payload": {
"type": 1,
"content": "I work in <mark>Beijing</mark>"
},
"topic": "",
"timestamp": 762835
}
]
}
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
Show payload fields
Show payload fields
string
Message content search keywords
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
curl -X POST "http://localhost:5001/plugins/wk.plugin.search/usersearch" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"payload": {
"content": "Beijing"
},
"payload_types": [1, 2],
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": ["payload.content"]
}'
const searchParams = {
uid: "user123",
payload: {
content: "Beijing"
},
payload_types: [1, 2],
channel_type: 2,
limit: 10,
page: 1,
highlights: ["payload.content"]
};
const response = await fetch('http://localhost:5001/plugins/wk.plugin.search/usersearch', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(searchParams)
});
const data = await response.json();
console.log(data);
import requests
search_params = {
"uid": "user123",
"payload": {
"content": "Beijing"
},
"payload_types": [1, 2],
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": ["payload.content"]
}
response = requests.post(
'http://localhost:5001/plugins/wk.plugin.search/usersearch',
json=search_params
)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
searchParams := map[string]interface{}{
"uid": "user123",
"payload": map[string]interface{}{
"content": "Beijing",
},
"payload_types": []int{1, 2},
"channel_type": 2,
"limit": 10,
"page": 1,
"highlights": []string{"payload.content"},
}
jsonData, _ := json.Marshal(searchParams)
resp, err := http.Post(
"http://localhost:5001/plugins/wk.plugin.search/usersearch",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"total": 25,
"limit": 10,
"page": 1,
"messages": [
{
"message_id": 1234,
"message_idstr": "1234",
"message_seq": 1,
"client_msg_no": "djzdfdfdf",
"from_uid": "u1",
"channel_id": "g1",
"channel_type": 2,
"payload": {
"type": 1,
"content": "Are you from <mark>Beijing</mark> University?"
},
"topic": "",
"timestamp": 762834
},
{
"message_id": 1235,
"message_idstr": "1235",
"message_seq": 2,
"client_msg_no": "djzdfdfde",
"from_uid": "u2",
"channel_id": "g1",
"channel_type": 2,
"payload": {
"type": 1,
"content": "I work in <mark>Beijing</mark>"
},
"topic": "",
"timestamp": 762835
}
]
}
Response Fields
integer
required
Total number of messages
integer
required
Query limit
integer
required
Current page number
array
required
Message list
Show Message object fields
Show Message object fields
integer
required
Message unique ID
string
required
Message unique ID (string format)
integer
required
Message sequence number
string
required
Client message unique number
string
required
Sender UID
string
required
Channel ID
integer
required
Channel type
object
required
string
Message topic
integer
required
Message timestamp (10-digit seconds)
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:
{
"payload": {
"content": "Beijing"
},
"highlights": ["payload.content"]
}
{
"payload": {
"content": "Are you from <mark>Beijing</mark> University?"
}
}
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:const timeRangeSearch = {
uid: "user123",
payload: { content: "project" },
start_time: 1640995200, // 2022-01-01
end_time: 1672531200, // 2023-01-01
limit: 20
};
const typeSearch = {
uid: "user123",
payload_types: [1, 2], // Text and image messages only
channel_id: "group123",
limit: 50
};
const complexSearch = {
uid: "user123",
payload: { content: "meeting" },
from_uid: "manager123",
channel_type: 2,
topic: "work",
highlights: ["payload.content"],
limit: 10
};
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

