You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### 2. Search bar autocomplete — configurable page size with pagination
108
+
### 2. Search bar autocomplete — configurable top-N display
109
109
110
110
**Added**: 2026-04-27
111
-
**Last verified**: 2026-04-27
111
+
**Last verified**: 2026-04-28
112
112
**Branch**: `abhiroop93/feat/hyperdx-upgrade`
113
113
114
-
**Intent**: The autocomplete dropdown was hardcoded to show a maximum of 10 suggestions with no way to see the rest. This change makes the per-page limit configurable via env var and adds prev/next pagination controls when the result set exceeds one page. Keyboard navigation (ArrowUp/Down) crosses page boundaries automatically.
114
+
**Intent**: The autocomplete dropdown was hardcoded to show a maximum of 10 suggestions with no way to configure it. This change makes the visible limit configurable via env var. Pagination was considered but removed — the per-keystroke ClickHouse prefix search (customization #3) makes pagination unnecessary because the result set is already narrowed server-side. A "Showing Top N" label appears when results are trimmed.
115
115
116
116
#### Environment variables introduced
117
117
118
118
| Variable | Type | Default | Description |
119
119
|---|---|---|---|
120
-
|`NEXT_PUBLIC_AUTOCOMPLETE_SUGGESTIONS_LIMIT`| integer |`10`| Max suggestions shown per page in the autocomplete dropdown |
120
+
|`NEXT_PUBLIC_AUTOCOMPLETE_SUGGESTIONS_LIMIT`| integer |`10`| Max suggestions shown in the autocomplete dropdown |
Add pagination state, derive `pagedSuggestions`, add prev/next controls. See git diff for full implementation.
141
+
- Removed `Fuse.js` — replaced with `opt.value.toLowerCase().includes(searchTerm.toLowerCase())` for client-side filtering of the ClickHouse result set
142
+
- Removed all pagination state (`page`, `totalPages`, `pagedSuggestions`, prev/next buttons)
143
+
- Renders `suggestedProperties.slice(0, pageSize)` directly with a "Showing Top N" hint when trimmed
144
+
- Simplified ArrowUp/Down to navigate within `0..visibleSuggestions.length-1`
142
145
143
146
---
144
147
145
-
### 3. Search bar autocomplete — per-keystroke value filtering
148
+
### 3. Search bar autocomplete — per-keystroke ClickHouse prefix search
146
149
147
150
**Added**: 2026-04-27
148
-
**Last verified**: 2026-04-27
151
+
**Last verified**: 2026-04-28
149
152
**Branch**: `abhiroop93/feat/hyperdx-upgrade`
150
153
151
-
**Intent**: The autocomplete dropdown only triggered once when a field name was fully typed. Suggestions now narrow with every character entered in the value portion. Field detection and clearing both operate on the last quote-aware token so multi-token queries and quoted values with spaces are handled correctly. A minimum-character threshold prevents the dropdown from appearing on very short inputs.
154
+
**Intent**: The original autocomplete fetched a fixed top-N values for a field once (e.g. all `ServiceName` values) and filtered client-side. This had two problems:
155
+
1. If the target value wasn't among the top N fetched, it could never appear regardless of what the user typed.
156
+
2. Filtering was done by Fuse.js with `threshold: 0`, which scored substring matches slightly above 0 due to the pattern/text length ratio, causing valid matches like `user-entity` inside `user-entity-service` to be dropped.
157
+
158
+
The fix uses two layers:
159
+
-**ClickHouse-side**: Each debounced keystroke adds `WHERE field ILIKE 'prefix%'` to the `chartConfig` so React Query fires a new targeted query. This bypasses the top-N limit entirely for specific searches.
160
+
-**Client-side**: After the ClickHouse result returns, `String.prototype.includes()` filters the result set for the dropdown display.
161
+
162
+
Field detection operates on the last quote-aware token so multi-token queries (`level:"info" ServiceName:"user`) and negation (`-ServiceName:"foo`) are handled correctly.
163
+
164
+
The hook also returns `keyValCompleteOptions` directly (not merged with `fieldCompleteOptions`) so field names never bleed into the value-completion dropdown.
152
165
153
166
#### Environment variables introduced
154
167
155
168
| Variable | Type | Default | Description |
156
169
|---|---|---|---|
157
-
|`NEXT_PUBLIC_AUTOCOMPLETE_MIN_CHARS`| integer (≥ 0) |`1`| Minimum characters in the value portion before suggestions appear |
Rework field-detection and `suggestedProperties` useMemo to use quote-aware tokenizer. See git diff for full implementation.
225
+
1.**Field detection** — operates on the last quote-aware token via `getLastToken` + `stripNegation`. Supports `field:value` in-progress form, negation, and multi-token queries.
226
+
227
+
2.**Field clearing** — clears `searchField` when the last token no longer starts with the detected field name, so typing a second field correctly re-fetches for the new field.
228
+
229
+
3.**Debounced ClickHouse prefix filter** — extracts the value prefix from the typed input, debounces it 300ms, and adds it to `chartConfigs.where`:
React Query detects the changed `chartConfig` object and fires a new query. Single-quotes in the prefix are escaped to prevent SQL injection.
234
+
235
+
4.**Configurable date range** — `dateRange` uses `AUTOCOMPLETE_DATE_RANGE_MS` instead of the hardcoded 12-hour window.
236
+
237
+
5.**Return value** — returns `keyValCompleteOptions` directly instead of `deduplicate2dArray([fieldCompleteOptions, keyValCompleteOptions])`. When `searchField` is active and `keyVals` are loaded, only formatted value pairs are returned (not field names). Falls back to `fieldCompleteOptions` when no field is detected or values are still loading.
0 commit comments