Search messages and chats by words or meaning
Find a message, an agreement, a person or a file in your chats by words, word forms or meaning, and check the messages around it.
Find a message, an agreement or a file even when you remember only part of a phrase or what it was about. Your agent searches the history saved on your computer, and the messenger's own search too, then shows the message and what was said around it, so you can check the answer.
Search finds a word in any of its forms, and with a little setup it also finds a discussion by its meaning. It finds what is saved or what the messenger's server returns, so download the chats you need first. An empty result does not prove a message was never sent. The examples use Telegram and MAX, and Search in other tools covers WhatsApp, Slack, mail, calls and documents.
What you can search:
- Messages and discussions: by text, sender, date, subject and nearby messages.
- People: by name, username or ID, then what you discussed. People
- Chats, groups and channels: by title.
- Files: by name and type, and by the words inside a text file, a Word document or a PDF with a text layer. A scan or a photo needs text recognition first, and your agent can run it.
- Links, attachments and voice notes: messages with a link, a PDF or a voice note, and the words said in a voice note once its transcript is saved.
How word forms, typos and search by meaning work: How search works. What each kind of content needs before it can be found: What gets indexed.
On this page:
- Fetch the relevant chat history first
- Find a word or phrase
- When you don't remember the exact wording
- Read the evidence, then widen
- Search everything at once
- Search in other tools
- If a result is missing
- Try it with sample messages
- Commands, filters and operators
- Search CRM deals and keep work apart
- More precise queries and technical details
Fetch the relevant chat history first
Before you search older messages, download the chats for the period you need. Signing in does not download all history. Word search in tg and max also asks the messenger's server by default, so it can find messages you have not downloaded yet. Topic search, counts and file filters read only saved messages, and --backend archive keeps a word search on your computer too. If the chat is missing, an empty result does not mean the message was never sent.
Ask your agent to fetch the selected chats or run your messenger's command. Replace Project
with the chat title; this example downloads the past month, up to 1,000 messages per run:
tg personal messages sync "Project" --since-time 30d --limit 1000max personal messages sync "Project" --since-time 30d --limit 1000If the limit is reached, that month's history may still be incomplete. Instructions for fetching, resuming and checking history: Telegram and MAX.
Find a word or phrase
Start by asking your agent. For MAX, write “max CLI” instead of “tg CLI”:
Use tg CLI. Find where we agreed the renovation deadline in the group and my chat with the contractor. Show the final agreement, check later replies and cite the messages. If history is missing, tell me what needs fetching. Don't send anything.You should get the agreed date and the messages behind it. If the date was only proposed or later changed, the answer should make that clear. You do not need to know the search syntax.
Optional: commands for the terminal
tg personal search messages invoice
max personal search messages invoiceFor an exact phrase, keep the quotes inside the query:
Optional: commands for the terminal
tg personal search messages 'exact:"final invoice"'
max personal search messages 'exact:"final invoice"'Results link back to messages. Ask your agent to show nearby messages before interpreting an agreement: one line may miss a correction or a later answer.
To search one chat only:
Optional: commands for the terminal
tg personal search messages 'invoice chat:"Project"'
max personal search messages 'invoice chat:"Project"'You can also filter by person, date or attachments. The Telegram and MAX guides give examples you can adapt.
When you don't remember the exact wording
Message search offers several approaches:
- A word or exact phrase: when you remember the wording. Use
exact:for literal matching. - Part of a word:
flat*finds words starting with that part, such as “flat” and “flats”. - Word forms and shared stems: “invoice” can find “invoices”. Which forms match depends on the archive's language settings.
- Typos: the default search does not correct typos. Ask your agent to allow misspellings: it can add
--discover, which also tries close spellings of the words in the local archive, or search by the start of the word. - Meaning: when you remember the subject, such as “the renovation deadline we agreed”, rather than the words. This needs a prepared discussion index.
Word forms, exact matching, indexes and meaning-based search: How search works.
Detailed syntax: Telegram and MAX. The --discover option is listed in the command references for Telegram and MAX. These modes describe message search;
chat-title and person-name lookup can behave differently.
Words inside files and transcripts match the exact form only.
Use search conversations when you remember what a discussion was about and not which words were used. Ask in your own words, in any language the model reads. It always returns the nearest conversations, even when none of them answers, so open the messages before you rely on one. For an exact name, number or id, use a field search instead. More: Topic search.
Read the evidence, then widen
Open one hit with its neighbors, or follow its reply chain:
tg personal messages context "msg:telegram/1/77/42" --before-n 3 --after-n 3
tg personal messages context "msg:telegram/1/77/42" --threadIf an answer looks thin, read its missing entry. It names what was not searched and the step that fixes it, such as downloading a chat. Each hit says where it matched (matched_in: text, transcript, filename or file). To compare the count with what you expect, stats messages show counts matches by chat, sender, day or hour.
Search everything at once
When you do not know whether something was written in a chat or in your own notes, search both together:
tg personal search all invoice
max personal search all invoiceEach result says whether it is a message or a note. tg and max do not search mail: wcat search mail
does, and wcat search all invoice searches messages, mail and notes at once.
Search in other tools
The same requests work in the other tools: name the tool in your request instead of tg. Each one searches what it copied to your computer, and some ask their service too.
- WhatsApp:
wa search messagessearches the messages saved on your computer. WhatsApp search - Slack:
slk search messagesalso asks Slack's server by default, astgdoes. Slack - Mail:
mail search messagesalso asks the mail server for mail not downloaded yet. Search your mail - Zoom:
zm search meetingsfinds words in your saved meetings, and searches by meaning with--model. Zoom search - Documents:
drive search,notion searchandydisk searchfind words in the documents they copied, and search by meaning once the documents are indexed.
If a result is missing
Topic search, counts and filters such as files or links need saved history: download the missing period, then search again. A word search and a search by meaning find different things, so try both when you remember only roughly how something was said. Check the dates, the chats searched and whether the history is complete.
Open the source of the best hit and compare it with what you remembered. If a kind of content never turns up, check the one step it needs: What gets indexed. If a link between records is missing, see How things are linked.
Try it with sample messages
Practice combining filters and checking sources before connecting an account. This playground contains 50 fictional messages in 6 chats, runs on your device and never connects to a messenger. The sample messages are in English: try invoice, budget or coffee.
- Start with a word or choose a filter.
- Narrow the results by person, chat, date or attachment type.
- Open a match to read its context, then change a filter and compare the results.
Sample dates run from two days before today to two days after it and use UTC. Type a field such as has: or in: to see its values. Press Space after a word or completed filter to see fields and operators; use ↑ / ↓ and Enter to insert a suggestion, or Esc to close it. Clear the query or choose All to browse every message.
Build a Lucene query
Lucene syntax combines words with fields and logical operators. Start with invoice, then add conditions to narrow the result. Use uppercase AND, OR and NOT, and parentheses to make the grouping clear.
| Query | What it finds |
|---|---|
invoice AND budget | Messages containing both words. |
Atlas AND (invoice OR budget) | Atlas messages containing either invoice or budget. |
invoice NOT has:file | Invoice messages without a file attachment. |
"final invoice" | The words together, in that order. |
text:cof* | Words starting with cof, including coffee. |
text:*off* | Words containing off, such as coffee or office. ? replaces one character. |
chat:"Client studio" AND from:Mia | Messages from Mia in Client studio. Quote names containing spaces. |
in:max AND has:voice | Voice notes from a selected messenger. Choose a messenger from the in: suggestions. |
text:coffee finds the word coffee. text:cof searches for the whole word cof, so it does not match coffee; add * when you only remember part of a word.
has: also offers attachment, link, file, photo, image, video, audio, sticker, contact, location and poll. has:attachment includes attached media; has:link finds links in the message text. You can combine them: (has:file OR has:link) AND text:budget.
Choose Date for today's date, the current month or the five-day sample window. The inserted query uses date:YYYY-MM-DD for a day or date:[START TO END] for an inclusive range. An asterisk leaves one end open; braces exclude the boundary. For example, the Before tomorrow suggestion uses date:{* TO YYYY-MM-DD} with tomorrow's date.
This playground implements the supported WireCat Lucene fields, rather than every Apache Lucene feature. Fuzzy matching (~), boosting (^) and fields such as filename: are unavailable here. An unfinished or unsupported query keeps the previous valid results visible and marks the problem; it does not silently broaden the search.
Commands, filters and operators
For running the commands yourself, or for steering what your agent runs. Put the tool name and your profile name in front of each command, as in tg personal search messages.
Choose the command
| You want | Run | Notes |
|---|---|---|
| Words in your Telegram or MAX messages | search messages in tg or max | Reads the local archive and, by default, the messenger's server |
| A phone, email, link or person's name written in messages | search messages with phone:, email:, domain: or mentions:, or mentions list | Found by rules, in any spelling |
| Everything about one person, in every messenger | contacts events | Needs the identities linked with contacts link |
| A discussion, when you remember the subject and not the words | search conversations | Needs conversations rebuild and conversations embed once for the chat |
| A picture by what it shows | search messages "dog on a beach" | English only, and the picture setting must be on: What gets indexed |
| Mail, notes, or you do not know where it was written | wcat search all, wcat search mail, wcat search notes | The answer lists the sources it skipped and why |
| Messages of every messenger at once | wcat search messages | Messages only |
| A decision or a promise | wcat facts list | Each fact links to its evidence |
| A Drive document, by words or meaning | drive search | --exact for words only |
| A Drive file, by name, type, folder, person or tag | drive catalog list or drive catalog search | Metadata only, works offline |
Narrow first, then search
A search that names a chat, a sender and a period reads fewer records and returns fewer wrong ones. Add filters in this order: chat, sender, date, kind, attachment, then the words.
| Filter | Finds | Example |
|---|---|---|
chat: | One chat, by name or id | chat:"Book club" |
from: | One sender | from:"Kai Sample" |
date: | A period, or everything after a day | date:[2026-01-01 TO 2026-02-01}, date>=2026-10-01 |
kind: | Private chats, groups, channels, bots | kind:group |
has: | Messages with a file, photo, voice note, link or text | has:file |
filename: | A file by its name | filename:*.pdf |
mime: | A file by its type (Telegram only) | mime:"application/pdf" |
size: | Files by size | size>10MB |
content: | Words inside a file | content:invoice |
transcript: | Words said in a voice note | transcript:invoice |
tag: | Your own labels | tag:work |
phone:, email:, url:, domain:, mentions: | A value found in the text | phone:"+1 555 010 0100", mentions:"person:7" |
Field names are case sensitive, and an unknown field is an error, not an empty answer. The full list of fields is in the query language of Telegram and MAX.
tg personal search messages 'chat:"Book club" from:"Kai Sample" date>=2026-10-01 delivery' --limit 10When the messenger's own server is asked too, only the words, one chat, one sender and the dates go to it. has:, tag:, negations and wildcards are applied locally. Details: How search works.
The operators
| Write | Meaning |
|---|---|
invoice paid | Both words, in any order (AND is the default) |
alpha OR beta | Either word |
alpha NOT beta, alpha -beta | The first word without the second |
+alpha | The word must be there |
(alpha OR beta) gamma | A group |
from:(alice OR bob) | One field for several values |
date:[2026-01-01 TO 2026-02-01} | A range: [ ] includes the end, { } excludes it |
invo* | Any ending |
text:/pass(port)?/ | A regular expression, matched against whole words |
Three rules prevent most surprises:
- A query that is only a negation selects nothing. Pair it with a positive condition:
has:photo NOT has:text. - An explicit
ANDbinds tighter thanOR.alpha OR beta gammameans(alpha OR beta) AND gamma. and,orandnotin lower case are ordinary words. Typos such asinvoice~1and boosts such asinvoice^2are errors.
Page through the results
The answer says whether more results exist (has_more). That describes the page, not whether the messenger holds more. Repeat the same command with the same filters and ask for the next page. Which flag does it depends on the command:
| Command | Next page |
|---|---|
search messages in tg and max | --page <n>, counting from 1 |
contacts events | --cursor <cursor>, with the cursor from the answer's page.next |
mentions list, drive catalog list, drive catalog search | --page <n> |
wcat search notes, drive search | --offset <n> |
wcat search all, wcat search mail, wcat search messages | --limit only, up to 100: narrow the query instead |
Keep the output small
--limit <n>caps the hits.--json=<fields>keeps only the fields you name, for example--json=ref,date,text. It is the one option that shrinks every answer: 31% to 64% smaller than full--jsonin our measurement.--jsonlprints one result per line. It is no smaller than--json.--fullreturns whole texts.--max-output-bytescaps machine output at 4 MiB by default. A result over the cap fails visibly instead of being cut.--context <n>addsnneighboring messages on each side of a hit. It is 0 when the output is not a terminal.
Recipes
Replace the names with yours.
| Goal | Command |
|---|---|
| An agreement and its source | tg personal search messages 'chat:"Book club" agreed date>=2026-10-01' --limit 5 |
| Everything about one person this month | tg personal contacts events "Kai Sample" 'at>=2026-10-01' |
| Where a phone number appears | tg personal search messages 'phone:"+1 555 010 0100"' |
| Files sent in a chat last week | tg personal search messages 'chat:"Book club" has:file date>=2026-10-07' |
| What a Drive document says about a topic | drive personal search 'budget' --exact --limit 5 |
For longer ones, see the recipes for Telegram and MAX.
Common mistakes
| Mistake | What happens | Instead |
|---|---|---|
| Searching before the history is downloaded | Few or no results | Download the chat first; read missing in the answer |
| Reading an empty answer as "never sent" | The archive may be incomplete | Check what the answer says it covered |
| Quoting a phrase to get the exact form | Quotes match any word form | exact:"final invoice" |
mime:application/pdf without quotes | The / starts a regular expression | mime:"application/pdf", or filename:*.pdf |
mime: in MAX | MAX does not report file types | filename:*.pdf |
has:photo to find what a picture shows | It only says a photo is attached | Picture search, in English |
| A message field in a Drive search | Drive has its own filters | tag: and --exact, or catalog list |
From: instead of from: | An error | Field names are lower case |
| Asking a picture search in another language | The model knows English only | Have your agent translate first |
Search CRM deals and keep work apart
wcat search all also finds the deals and leads a CRM tool such as b24 stored, by the words of
their title. --only crm searches them alone:
wcat search all 'renewal' --only crmPeople and companies are not in search all. Find them with wcat search people and wcat organizations list.
A deal outside the CRM account's sync scope is not found either.
An agent that uses wcat's MCP server sees in search all only what its permissions
let it list. When the server denies deals.list or leads.list, those hits are left out, and the answer says so in an
issue for crm. crm.list leaves the whole CRM part out, and business.list leaves out invoices, payments, orders,
contracts, subscriptions, products and wallets. --only crm and --only business search one part alone, and are
refused when that part is denied. These permissions do not limit a search you run yourself in a terminal.
wcat search all 'renewal' --only businessA question about who someone is, or how a person, a company and a deal relate, is better answered from their context than from search. Ask your agent to work in this order:
- Find the one record:
wcat search people,wcat organizations listorwcat deals list. - Read its context:
wcat context person:<id>,wcat organizations context <ref>orwcat deals context <ref> --brief. - Follow only the relationships the question needs, for example
wcat relationships list kind:reports-to 'to:"person:12"'. - Search for the evidence after that, with
wcat search all. - Cite the references, and name every gap the answer lists under "Not read". A
reportedrelationship is only the CRM's word.
Clients, colleagues and deals shows these answers with examples.
Groups of accounts
A group keeps your work accounts apart from your personal ones. With no group named, a run reads every account:
that is the group all, which always exists and never leaves anything out. personal, work and any other group
are groups you save yourself. Put the CRM account and your work mailbox in work, then name the group first, and
the run reads only its accounts:
wcat groups add work bitrix24:example.bitrix24.com
wcat groups add work email:owner@northstar.example
wcat groups add personal telegram:100
wcat groups add personal email:owner@northstar.example
wcat groups list
wcat work search all 'renewal'An account can be in two groups. wcat groups list shows each saved group, then all, and marks every account that
another group holds too. Duplicates are allowed, and the list ends with them. It also shows each account's profile
names in every tool, such as the profile work in tg and in b24, once those tools have run. A profile named like a group is only
a suggestion and never puts an account in that group.
$ wcat groups list
work
bitrix24:example.bitrix24.com
email:owner@northstar.example also in personal
personal
telegram:100
email:owner@northstar.example also in work
all
bitrix24:example.bitrix24.com all also in work
email:owner@northstar.example all also in work, personal
google-calendar:owner@northstar.example all
telegram:100 all also in personal
duplicate: email:owner@northstar.example is in work, personalwcat groups remove personal email:owner@northstar.example takes the mailbox out of personal, so it is no longer
a duplicate, and all still reads it. wcat groups move telegram:100 personal work moves an account in one write:
first the account, then the group it leaves, then the group it joins. A group you never saved does not exist: a run
that names it is refused, and the answer lists your groups and the profiles named like it. After the first sync of a
CRM account that no saved group lists, the sync's answer suggests wcat groups add work with that account. WCAT_GROUP=work works like the first word for every command. --source personal means
your own messenger accounts and not the group personal.
A group narrows the messages, mail, calendar events, CRM records and people a run reads. What you make yourself in
wcat belongs to no account, so it is in every group: your notes, projects, tasks, invoices, memories and facts.
wcat work search all 'renewal' finds the deal and the mail, and wcat personal search all 'renewal' finds only the
mail.
A run that names no group still reads every account. To keep an agent inside one group, start its wcat with
WCAT_GROUP_LOCK, for example WCAT_GROUP_LOCK=work wcat mcp serve. Under the lock, wcat refuses the messages,
mail, calendar events, CRM records and people of accounts outside the group. It also refuses another group,
--source all, an account outside the group and a change to the groups, and the agent cannot lift the lock. A
command that cannot keep to a group is refused as a whole, so the lock fails closed:
$ WCAT_GROUP_LOCK=work wcat messages show msg:telegram/100/201/1
{"error":{"code":"permission_error","reason":"access.denied","message":"this process is locked to group work (WCAT_GROUP_LOCK) — msg:telegram/100/201/1 belongs to an account outside it","details":{"reference":"msg:telegram/100/201/1"},"retry":{"safe":false}}}
$ WCAT_GROUP_LOCK=work wcat personal search all renewal
{"error":{"code":"permission_error","reason":"access.denied","message":"this process is locked to group work (WCAT_GROUP_LOCK) — group \"personal\" (first word) is refused","retry":{"safe":false}}}What the group holds still answers. Alice's context under the lock reads only the CRM account and counts the
accounts it kept out without naming them. Memories and facts leave out evidence and sources outside the group and
say how many they left out. wcat relationships list leaves out a row whose end only an outside account saw. Your
own tasks stay visible:
$ WCAT_GROUP_LOCK=work wcat context person:3
Alice person:3
...
Business
Organizations
Acme Ltd organization:1 member-of contact (Procurement manager) reported by bitrix24:example.bitrix24.com
...
Not read: other accounts — 2 outside group work
Read: bitrix24:example.bitrix24.com
$ WCAT_GROUP_LOCK=work wcat tasks list project:ATLA
ATLA-1 · open · chore · ATLA · Follow up on the Acme renewalWhich commands run under the lock: Lock an agent to a group.
More precise queries and technical details
Learn filters and operators in the Telegram query guide or MAX query guide. How search works explains indexing, conversations and ranking after the practical guides.
For the general grammar, read the official Apache Lucene query parser syntax. WireCat's references define which features work in the tools. The search architecture guide explains how message search, conversation graphs and embeddings fit together.
- What gets indexed: what can be found and what each kind of content needs.
- How things are linked: how messages, people, files, notes and tasks connect.
How to ask your agent
Write requests that give your AI agent a goal, a search scope and limits, for searches, meeting context, people, files, drafts and reminders you can check.
What gets indexed
Which kinds of content the tools make searchable (text, files, web pages, voice notes, pictures), what each needs, and what never leaves your computer.