Search for messages across all chats or in specific chats.
Args:
query: Search query string. Supports search filters (see below)
limit: Maximum number of results to return (default: 20)
chat_ids: Optional list of chat IDs to search within. If None, search in all chats.
Search Syntax:
Boolean Operators:
By default, all terms are optional (OR), as long as one term matches.
Search for "foo bar baz" finds any document containing foo OR bar OR baz.
+ (must be present) - Example: +fox (fox must be found)
- (must not be present) - Example: -news (news must be excluded)
Example: "quick brown +fox -news" (fox required, news excluded, quick/brown optional)
AND, OR, NOT (also &&, ||, !) - Standard boolean operators
NOTE: NOT takes precedence over AND, which takes precedence over OR
Example: "(quick OR brown) AND fox"
Grouping:
Use parentheses to group terms: "(quick OR brown) AND fox"
Wildcards:
? - Replace single character: "qu?ck"
* - Replace zero or more characters: "bro*"
Strict Search:
Use quotes for exact phrase match: "some search phrase"
Fuzziness:
Use ~ for similar terms (Damerau-Levenshtein distance, max 2 changes):
"quikc~ brwn~ foks~" or "quikc~1" (edit distance of 1)
Proximity Search:
Use ~N after phrase to allow words to be N positions apart:
"fox quick"~5 (allows up to 5 words distance, any order)
Search Filters:
Format: search text /filter1 param1 param2 /filter2 param
/users or /from - Find posts by specific users
Example: /users @user1 @user2 or /from @user1 @user2
/replyto or /reply - Find messages that are replies to specified users
Example: /replyto @user1 @user2 or /reply @user1 @user2
/to - Find messages that mention users OR are replies to them
Example: /to @user1 @user2
/file - Find files by name pattern
Example: /file *filen?me*
/from_date or /after - Find posts created after a date (YYYY-MM-DD, YYYY-MM, or YYYY)
Example: /from_date 2016-01-22 or /after 2016-01 or /after 2016
/to_date or /before - Find posts created before a date (YYYY-MM-DD, YYYY-MM, or YYYY)
Example: /to_date 2016-01-22 or /before 2016-01 or /before 2016
/tags - Find posts containing specific tags (strict match)
Example: /tags hey may day or /tags #hey #may #day or #hey #may #day
/has - Find posts based on content type:
/has tag - Posts containing tags (e.g., #may)
/has link - Posts containing URLs or markdown links
/has email - Posts containing email addresses
/has mention - Posts mentioning any user or user with role
/has user - Posts containing user mentions or words starting with @
/has group - Posts containing role mentions
/has reply - Posts that are replies
/has file - Posts with attached files
/has block - Posts with text in blocks (>text or ```text)
/has poll - Posts containing polls
Returns:
ToolResponse with SearchMessagesPayload containing search results with message text,
sender, chat info, and timestamp