Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Merge branch 'feature/partner-full-text-search' into feature/partner-full-text-search-rollout

Rafi78ad14c60aa8
diff --cc apps/web/lib/api/partners/search/providers/turbopuffer.ts
index adeaf8772c,ffd015a0e3..bf08647774
--- a/apps/web/lib/api/partners/search/providers/turbopuffer.ts
+++ b/apps/web/lib/api/partners/search/providers/turbopuffer.ts
@@@ -24,28 -23,10 +24,28 @@@ import { getEmailNgrams, getQueryNgram
* traffic from every program keeps the single namespace warm, while per-program
* namespaces would leave rarely-searched programs paying the cold-start cost on
* most queries. The whole workload also fits one namespace comfortably (all
- * programs together are ~1.6M enrollment documents). A secondary benefit is
- * that provider methods can work with bare document IDs, which carry no program
- * to pick a namespace by.
+ * programs together are ~1.6M enrollment documents).
+ *
+ * Bumped whenever the document shape changes, because turbopuffer keeps the
+ * schema a namespace was created with, and writing a new one does not migrate an
+ * existing namespace. A new version is backfilled alongside the old one and
+ * swapped in, rather than rebuilt in place.
+ */
+export const PARTNER_SEARCH_NAMESPACE = "partner-search-v3";
+const WRITE_BATCH_SIZE = 500;
+
+/**
+ * Below this, the counting aggregation is not worth attempting.
+ *
+ * The final token is a prefix, so a short one expands to every term beginning
+ * with it. Measured against 626K documents: one character takes the count from
+ * ~50ms to ~1.2s, past the query deadline on every attempt, and two characters
+ * are still 2-3x slower than three. The first keystrokes of a search fall back
+ * to the database count instead.
*/
+const MIN_COUNT_PREFIX_LENGTH = 3;
- const QUERY_OPERATION_TIMEOUT_MS = 1_000;
++const QUERY_OPERATION_TIMEOUT_MS = 2_000;
+
interface TurbopufferPartnerSearchRow extends Record<string, unknown> {
id: string;
programId: string;