Repository navigation
MCP docs: teach quoted Lucene exact-match form and the body-text token path #3560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@hyperdx/api': patch | ||
| --- | ||
|
|
||
| docs: Teach the quoted Lucene exact-match form (field:"value") and the bare-term/hasToken body-text path in MCP tool descriptions |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -881,11 +881,13 @@ Lucene field:value does NOT mean exact equality. It translates to ilike(field, ' | |
| ServiceName:api* does NOT mean "starts with api". It means "contains a substring starting with api". | ||
| In practice this often works for prefix matching, but it is NOT equivalent to SQL LIKE 'api%'. | ||
|
|
||
| For exact matching or true prefix/suffix/contains patterns, use SQL instead: | ||
| Exact: whereLanguage: "sql", where: "SpanKind = 'Server'" | ||
| Prefix: whereLanguage: "sql", where: "ServiceName LIKE 'api%'" | ||
| Contains: whereLanguage: "sql", where: "Body LIKE '%timeout%'" | ||
| Regex: whereLanguage: "sql", where: "match(ServiceName, '^api-v[0-9]+')" | ||
| For exact matching or true prefix/suffix/contains patterns: | ||
| Exact (stay in Lucene, QUOTE the value): SpanKind:"Server" (compiles to SpanKind = 'Server', uses the primary key) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — 'uses the primary key' is false for SpanKind in the default schema otel_traces is Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| Exact (SQL): whereLanguage: "sql", where: "SpanKind = 'Server'" | ||
| Prefix: whereLanguage: "sql", where: "ServiceName LIKE 'api%'" | ||
| Body text: prefer a bare Lucene term (timeout) or SQL hasToken(lower(Body), 'timeout') over LIKE '%timeout%' -- | ||
| the token path uses the text index; Body:term still compiles to substring ILIKE and scans the whole column. | ||
| Regex: whereLanguage: "sql", where: "match(ServiceName, '^api-v[0-9]+')" | ||
|
|
||
| When Lucene substring matching is FINE: free-text columns like Body, StatusMessage where substring is the intent. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — The new body-text guidance contradicts the next line, which still calls Body:term substring 'FINE' Line 889 now says Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| When Lucene substring matching is WRONG: enum-like columns (SpanKind, SeverityText, StatusCode, ServiceName) where you want exact or true prefix match. | ||
|
|
@@ -901,7 +903,7 @@ Lucene queries that reference map-attribute keys via dotted paths (http.status_c | |
|
|
||
| Reliable in Lucene (top-level columns only): | ||
| Duration:>1000000000 (top-level numeric range) | ||
| ServiceName:checkout (top-level string -- but remember this is a substring match, not exact!) | ||
| ServiceName:"checkout" (top-level string, quoted for exact match; unquoted ServiceName:checkout is substring!) | ||
|
|
||
| Workaround: switch to SQL with bracket access. Map values are stored as strings, so quote the comparison value. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 major — The recommended exact-match example SpanKind:"Server" matches no rows on real span data
The repo stores SpanKind as
SPAN_KIND_SERVER(see packages/app/tests/e2e/seed-clickhouse.ts:214, packages/api/src/mcp/tests/trace.int.test.ts:260, and the hdx-eval generators). Today the unquotedSpanKind:Serverstill matches by substring. The new quoted form compiles toSpanKind = 'Server'(queryParser.ts:2076 → eq) and returns zero rows, so an agent that follows this advice gets an empty tile. Change the example to an enum column whose stored value equals the literal, e.g.ServiceName:"checkout", or useSpanKind:"SPAN_KIND_SERVER". Make the same change in schemas.ts:23.Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond