Skip to content

Commit 23fe280

Browse files
os-zhuangclaude
andauthored
docs(search)+seed(showcase): document pinyin recall and make it demonstrable out of the box (#3034)
Follow-ups to the merged pinyin-search feature (ADR-0097, PR #3027): - environment-variables.mdx: new "Search" section documenting OS_SEARCH_PINYIN_ENABLED (locale-derived default, explicit override, what it gates). - queries.mdx: "Pinyin recall" subsection under Full-Text Search. - showcase seed: CJK-named account (华宁科技) and contacts (张伟/王芳/李雷) so the auto-enabled pinyin search is demonstrable out of the box. Verified on a fresh showcase boot: $search=zhangwei/zw/wf/huaning/hnkj all recall the seeded CJK records. Refs #2486 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RMugRriiNv3nsnmLczfhuY
1 parent 55bc68d commit 23fe280

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

content/docs/data-modeling/queries.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,19 @@ Only `query` and `fields` are implemented. The engine expands `search` into a dr
367367
are always AND-ed regardless of `operator`.
368368
</Callout>
369369

370+
### Pinyin recall (Chinese deployments)
371+
372+
When pinyin search is enabled (`OS_SEARCH_PINYIN_ENABLED` — auto-on when the stack's
373+
i18n config lists any `zh-*` locale, see
374+
[Environment Variables → Search](/docs/deployment/environment-variables#search)), records
375+
with CJK names are also found by typing their **full pinyin** or **initials**: searching
376+
`zhangwei` or `zw` matches a record named `张伟`, alongside the normal CJK and latin
377+
matching. This is transparent to queries and clients — the platform maintains a hidden
378+
`__search` companion column derived from each object's display/name field and ORs it into
379+
the expanded filter; `fields` semantics, `searchableFields`, and drivers are unchanged
380+
(ADR-0097). Relevance ranking and typo tolerance remain Tier-2 (native FTS) and are not
381+
part of this.
382+
370383
---
371384

372385
## Window Functions

content/docs/deployment/environment-variables.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,26 @@ OS_MCP_SERVER_ENABLED=true os start # additionally auto-start the stdio tran
235235

236236
---
237237

238+
## Search
239+
240+
Pinyin recall for `$search` (ADR-0097): with the switch on, every object's
241+
display/name field gets a hidden, platform-maintained companion column storing
242+
full pinyin + initials ("张伟" → "zhangwei zw"), so lookup pickers, list
243+
quick-search and ⌘K match `zhangwei` / `zw` against CJK names — transparently,
244+
with no client or object changes.
245+
246+
```bash
247+
os start # auto-on when the stack's i18n config lists any zh-* locale
248+
OS_SEARCH_PINYIN_ENABLED=true os start # force on regardless of locales
249+
OS_SEARCH_PINYIN_ENABLED=false os start # force off (e.g. a zh-locale stack that doesn't want the extra column)
250+
```
251+
252+
| Variable | Type | Default | Description |
253+
|:---|:---|:---|:---|
254+
| `OS_SEARCH_PINYIN_ENABLED` | boolean | locale-derived | Pinyin search recall. When unset, the default derives from the stack's configured locales (`i18n.defaultLocale` / `supportedLocales` / `fallbackLocale`): any `zh-*` locale turns it on; an explicit value always wins. Gates both the compile-time `__search` companion column and the `plugin-pinyin-search` populate hooks, so there is no half-state. Off ⇒ no extra column, and `pinyin-pro` is never loaded. |
255+
256+
---
257+
238258
## Marketplace & Metadata
239259

240260
| Variable | Type | Default | Description |

examples/app-showcase/src/data/seed/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const accounts = defineSeed(Account, {
4747
{ name: 'Initech', industry: 'finance', annual_revenue: 5_400_000, website: 'https://initech.example', status: 'active', hq: { lat: 30.2672, lng: -97.7431 }, tax_id: '74-2233110', billing_email: 'ap@initech.example' },
4848
{ name: 'Globex', industry: 'technology', annual_revenue: 42_000_000, website: 'https://globex.example', status: 'active', hq: { lat: 34.0522, lng: -118.2437 }, tax_id: '95-8841200', billing_email: 'billing@globex.example' },
4949
{ name: 'Stark Industries', industry: 'technology', annual_revenue: 180_000_000, website: 'https://stark.example', status: 'active', hq: { lat: 40.7580, lng: -73.9855 }, tax_id: '13-5567421', billing_email: 'ap@stark.example' },
50+
// CJK-named account so pinyin search recall (#2486) is demonstrable out of
51+
// the box: with the zh-CN locale configured, `$search=huaning` / `hnkj`
52+
// must find 华宁科技 in the record picker and list quick-search.
53+
{ name: '华宁科技', industry: 'technology', annual_revenue: 36_000_000, website: 'https://huaning.example', status: 'active', hq: { lat: 31.2304, lng: 121.4737 }, tax_id: '91-3100001', billing_email: 'billing@huaning.example' },
5054
{ name: 'Wayne Enterprises', industry: 'finance', annual_revenue: 210_000_000, website: 'https://wayne.example', status: 'active', hq: { lat: 40.7128, lng: -74.0060 }, tax_id: '22-9087733', billing_email: 'billing@wayne.example' },
5155
{ name: 'Acme Retail', industry: 'retail', annual_revenue: 3_200_000, website: 'https://acme.example', status: 'prospect', hq: { lat: 41.8781, lng: -87.6298 }, tax_id: '36-4471209', billing_email: 'accounts@acme.example' },
5256
{ name: 'Soylent Foods', industry: 'healthcare', annual_revenue: 9_900_000, website: 'https://soylent.example', status: 'prospect', hq: { lat: 37.3382, lng: -121.8863 }, tax_id: '77-1029384', billing_email: 'ap@soylent.example' },
@@ -69,6 +73,12 @@ const contacts = defineSeed(Contact, {
6973
{ name: 'Cara Ito', email: 'cara@contoso.example', phone: '+1 555 020 1111', company: 'Contoso', title: 'IT Director', account: 'Contoso', stage: 'new' },
7074
{ name: 'Carl Fox', email: 'carl@contoso.example', phone: '+1 555 020 2222', company: 'Contoso', title: 'Data Lead', account: 'Contoso', stage: 'qualified' },
7175
{ name: 'Faye Lin', email: 'faye@fabrikam.example', phone: '+1 555 030 1111', company: 'Fabrikam', title: 'Compliance Officer', account: 'Fabrikam', stage: 'new' },
76+
// CJK-named contacts so pinyin search recall (#2486) is demonstrable out
77+
// of the box: `$search=zhangwei` (full pinyin), `zw` (initials) and `张`
78+
// (CJK) must all find 张伟 in the people picker / list quick-search.
79+
{ name: '张伟', email: 'zhangwei@huaning.example', phone: '+86 21 5550 1111', company: '华宁科技', title: 'Engineering Manager', account: '华宁科技', stage: 'qualified' },
80+
{ name: '王芳', email: 'wangfang@huaning.example', phone: '+86 21 5550 2222', company: '华宁科技', title: 'Procurement Director', account: '华宁科技', stage: 'working' },
81+
{ name: '李雷', email: 'lilei@huaning.example', phone: '+86 21 5550 3333', company: '华宁科技', title: 'IT Specialist', account: '华宁科技', stage: 'new' },
7282
],
7383
});
7484

0 commit comments

Comments
 (0)