Logs, Term vs Grep search
Term search and grep search process your query differently. Understanding these differences helps you choose the right search type and avoid unexpected results.
How they work
Term search
Term search breaks your query into tokens and looks up each token in the search index.
-
Dots and underscores do not break tokens —
com.example.serviceandconnection_timeoutare each treated as a single token. -
Hyphens, colons, slashes, equals signs, brackets, and other punctuation do break tokens —
wire-formatbecomes two tokens:wireandformat. -
Tokens are lowercased automatically.
-
Common English words (stop words) such as
is,not,in,the,a,and,or,toare removed from the query. -
A log matches only if all remaining tokens exist in it.
-
Token order does not matter.
How special characters affect term search
The following table shows how term search tokenizes various inputs.
| Input | Tokens produced |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Examples
Each example below shows a full log line, the tokens produced by term search indexing, and then how various searches behave with both term and grep.
Log line: cannot parse invalid wire-format data
Indexed tokens: cannot, parse, invalid, wire, format, data
| Search | Term | Grep | Why |
|---|---|---|---|
|
✅ |
✅ |
Tokens |
|
✅ |
❌ |
Token order doesn’t matter for term; but no literal |
|
✅ |
✅ |
Tokens |
|
✅ |
❌ |
Same tokens; but no literal |
|
❌ |
❌ |
|
|
❌ |
✅ |
No tokens |
Log line: com.example.service.scheduler.QuartzJob started
Indexed tokens: com.example.service.scheduler.quartzjob, started
| Search | Term | Grep | Why |
|---|---|---|---|
|
✅ |
✅ |
Full token match (lowercased); exact substring exists |
|
❌ |
✅ |
Term search requires an exact token match; partial matches (even prefixes of a token) are not supported. Grep finds this substring |
|
❌ |
✅ |
Not a standalone token — it is part of the larger dot-separated token. Grep finds substring |
|
❌ |
✅ |
No such token (indexed lowercased as part of larger token). Grep finds substring |
|
✅ |
✅ |
Exact token match; exact substring exists |
Log line: invalid data in the message
Indexed tokens: invalid, data, message
| Search | Term | Grep | Why |
|---|---|---|---|
|
✅ |
✅ |
|
|
✅ |
❌ |
Same tokens after stop word removal → same term results; but no literal |
|
❌ |
❌ |
Both words are stop words → empty query → no match; no substring either |
Log line: info sbr/skill_based_routing_controller.go:1920 GetChannelList
Indexed tokens: info, sbr, skill_based_routing_controller.go, 1920, getchannellist
| Search | Term | Grep | Why |
|---|---|---|---|
|
✅ |
✅ |
Full token match (dots and underscores kept); exact substring exists |
|
❌ |
✅ |
Not the full token. Grep finds substring |
|
❌ |
✅ |
Not a standalone token. Grep finds substring |
Log line: 2024-01-15T10:30:00Z [ERROR] GET /api/v2/users?id=123 failed: connection_timeout (retries=3)
Indexed tokens: 2024, 01, 15t10, 30, 00z, error, get, api, v2, users, id, 123, failed, connection_timeout, retries, 3
| Search | Term | Grep | Why |
|---|---|---|---|
|
✅ |
✅ |
Token |
|
❌ |
❌ |
Token |
|
❌ |
✅ |
Indexed as |
|
✅ |
✅ |
Token |
|
✅ |
✅ |
Lowercased to |
|
✅ |
❌ |
Token |
|
❌ |
❌ |
|
|
✅ |
❌ |
|
|
✅ |
✅ |
Brackets stripped → token |
|
✅ |
✅ |
Tokens |
|
✅ |
✅ |
Tokens |
|
✅ |
✅ |
Tokens |
|
✅ |
✅ |
Tokens |
|
✅ |
❌ |
Same tokens (lowercased); but log has |
|
❌ |
✅ |
Search tokens are |
Log line: error1500 is not a valid response
Indexed tokens: error1500, valid, response
| Search | Term | Grep | Why |
|---|---|---|---|
|
❌ |
✅ |
Token is |
|
❌ |
✅ |
Token is |
|
❌ |
✅ |
Both are stop words → removed → empty query. Grep finds exact substring |
|
❌ |
✅ |
All stop words → empty. Grep finds exact substring |
Key differences summary
Term search misses when:
-
The search is a substring of a token rather than the complete token — for example,
schedulerdoes not match the tokencom.example.service.scheduler.QuartzJob. -
The search consists entirely of stop words — for example,
is notproduces an empty query after stop word removal.
Key gotcha: dots (.) and underscores (_) do not split tokens. user.name and connection_timeout are each a single token.
When to use which
| Use case | Recommended |
|---|---|
Keyword search (e.g., "find logs with error and timeout") |
Term search |
Exact substring (e.g., "find |
Grep search |
Search for part of a dotted name (e.g., |
Grep search |
Search for stop words as part of a phrase (e.g., |
Grep search |
Fast, broad search across many logs |
Term search |