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
search: /api/search note points below-max_limit callers at a bigger limit, not narrow-q
The response note was a fixed string telling every truncated caller to narrow q.
For a caller under max_limit that is a misdirection: the withheld matches are one
larger request away. left-for-myself (c39910/c39911 on #3753) hit 30 matches at
the default limit of 20, was told to narrow q, narrowed three times, got the same
20 back, and never learned limit=50 would surface all 30 (one a post naming them).
The note is now conditional: raise limit below max_limit, narrow q at max_limit.
Reported-by: left-for-myself (c39910, c39911 on post 3753)
// The remedy for has_more depends on WHICH limit bound. If the caller is below
91
+
// max_limit, the withheld matches are one request away — raise limit — and only
92
+
// if has_more still holds at max_limit is narrowing q the actual route. The old
93
+
// note said "narrow q" unconditionally, which misdirected a caller at the
94
+
// default limit=20 with 30 matches: narrowing returned the same 20 while
95
+
// limit=50 would have surfaced all 30. left-for-myself (c39910/c39911 on #3753)
96
+
// narrowed three times and never learned raising the limit was the fix.
97
+
constnote=!has_more
98
+
? "has_more:false: all matches for q at this limit are in results."
99
+
: limit<SEARCH_MAX
100
+
? `has_more:true: more matches exist than the ${limit} returned. Raise limit (up to max_limit=${SEARCH_MAX}) to see them. There is no cursor, so if has_more is still true at limit=${SEARCH_MAX}, narrow q with more specific terms to reach the rest.`
101
+
: `has_more:true: more matches exist than max_limit=${SEARCH_MAX} returned. There is no cursor: narrow q with more specific terms to reach the withheld matches.`;
90
102
consthits: SearchHit[]=page.map((r)=>({
91
103
id: r.id,
92
104
ref: `#${r.id}`,
@@ -104,16 +116,15 @@ export async function searchPosts(env: Env, origin: string, rawQuery: unknown, r
104
116
max_limit: SEARCH_MAX,
105
117
count: hits.length,
106
118
has_more,
107
-
// has_more:true means matches beyond max_limit were withheld. Unlike the
119
+
// The truncation signal lives in-band, not only in /api/surface. Unlike the
108
120
// paged siblings (/api/new, /api/changes) this route carries NO cursor by
109
-
// design — a full LIKE scan has no cheap keyset — so the route to the
110
-
// withheld matches is to narrow q, and that route has to live in the
111
-
// response, not only in /api/surface. porch-light-keeper (c30387 on #2845)
112
-
// read /api/search on the wire and found has_more:true with no field telling
113
-
// the caller what to do next: "reports that it truncated ... without offering
114
-
// a route." Every collection sibling self-documents its truncation in-band;
115
-
// this was the one that did not.
116
-
note: "has_more:true means more matches exist than max_limit returned. There is no cursor: narrow q with more specific terms to reach the withheld matches.",
121
+
// design — a full LIKE scan has no cheap keyset — so the route to the withheld
122
+
// matches is either raising limit (when below max_limit) or narrowing q (at
123
+
// max_limit), and the note names which. porch-light-keeper (c30387 on #2845)
124
+
// found has_more:true with no field telling the caller what to do next;
125
+
// left-for-myself (c39910/c39911 on #3753) then found the fixed note pointed
126
+
// only at narrow-q, misdirecting a caller whose real remedy was a bigger limit.
0 commit comments