◉RORK LABJP
●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SONNET 4.5 — Retires on the Claude API on 11/30, 31 days left. If your app calls it, check the migration target●SDK 58 ISSUE — Early reports include Android widgets not refreshing on a schedule and Stripe linking statically●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SONNET 4.5 — Retires on the Claude API on 11/30, 31 days left. If your app calls it, check the migration target●SDK 58 ISSUE — Early reports include Android widgets not refreshing on a schedule and Stripe linking statically●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…
Articles/Dev Tools
⬡ Dev Tools/2026-08-02Advanced

When Two-Character Queries Silently Return Nothing: Measuring Japanese Search Indexes in an Expo App

SQLite FTS5's trigram tokenizer returns zero rows for Japanese queries shorter than three characters, without raising anything. I benchmarked linear scan, a bigram inverted index, and FTS5 over a 20,000-item catalog to find the real threshold.

Rork611Expo234SQLite3FTS5Japanese searchPerformance25

✦ Premium Article

One morning I typed 猫 (cat) into my own app's search box and got an empty list.

I tried again, in case I had mistyped. Same result, instantly. The catalog holds more than six hundred cat titles. No error in the logs. No crash. Just nothing.

The cause was a search index I had shipped the week before. The catalog had grown, I decided a linear scan was surely running out of road, and I moved the whole thing onto SQLite's FTS5. It did get faster. It also dropped the single most common query length in Japanese, entirely.

What follows is what I found after sitting down and measuring properly. I ran a linear scan, a bigram inverted index, and FTS5 trigram over identical data to decide by numbers rather than intuition. The short version: I removed the index and went back to the linear scan.

Setting up something reproducible

Real catalog data can't be shared, so I generated a synthetic one deterministically. Titles follow a modifier + subject + suffix pattern, with three tags each, producing roughly 13–20 normalized characters per record — close to the real distribution.

// gen.mjs — linear congruential generator, so the same seed yields the same catalog
let seed = 20260802;
const rnd = () => (seed = (seed * 1103515245 + 12345) & 0x7fffffff) / 0x7fffffff;
const pick = (a) => a[Math.floor(rnd() * a.length)];
 
const subj = ["夜景", "桜", "富士山", "海", "星空", "猫", "森", "雪原", "花火", "滝", "紅葉", "銀河"];
const mod  = ["静かな", "淡い", "鮮やかな", "霧の", "真夜中の", "冬の", "黄昏の", "雨上がりの"];
const suf  = ["の風景", "のシルエット", "のグラデーション", "のパノラマ", "", ""];
const tagp = ["ミニマル", "ダーク", "パステル", "モノクロ", "和風", "自然", "高解像度", "縦向き"];
 
export function makeCatalog(n) {
  const out = [];
  for (let i = 0; i < n; i++) {
    out.push({
      id: "w" + i,
      title: pick(mod) + pick(subj) + pick(suf),
      tags: [pick(tagp), pick(tagp), pick(tagp)],
    });
  }
  return out;
}

Normalization has three layers: NFKC to collapse full-width and half-width forms, lowercasing, katakana folded to hiragana, and whitespace stripped. Absorbing orthographic variation is the well-trodden part. What mattered this time was the cost of running this function at all.

const norm = (s) =>
  s
    .normalize("NFKC")
    .toLowerCase()
    .replace(/[ァ-ヶ]/g, (c) => String.fromCharCode(c.charCodeAt(0) - 0x60))
    .replace(/\s+/g, "");

Everything ran in a Linux container on Node 22.22 and Python 3.10 (SQLite 3.37.2) — not on an iPhone. Read the ratios and orders of magnitude, not the absolute values. I have not measured the on-device multiplier this time, so please re-measure on your own phone.

The naive linear scan goes much further than expected

I started with the do-nothing implementation: build an array of normalized keys at load, then walk it with indexOf per query.

// Keep normalized keys in a flat array of strings
const keys = new Array(items.length);
for (let i = 0; i < items.length; i++) {
  keys[i] = norm(items[i].title + items[i].tags.join(""));
}
 
function search(q) {
  const nq = norm(q);
  const hits = [];
  for (let i = 0; i < keys.length; i++) {
    if (keys[i].indexOf(nq) >= 0) hits.push(i);
  }
  return hits;
}

Eight queries, twenty runs each, medians below. For contrast I also measured filter over an array of { id, k } objects.

ItemsFlat string arrayObject array + filterApprox. key memory
20,0000.80 ms1.11 ms1.4 MB
50,0001.99 ms2.79 ms3.6 MB
100,0004.05 ms6.48 ms7.2 MB
200,0008.50 ms12.43 ms14.4 MB
500,00020.21 ms29.65 ms35.9 MB

A 60fps frame budget is 16.7 ms. In this environment the scan stayed inside one frame up to 200,000 items. Devices will be slower than this container, but a catalog in the tens of thousands is comfortably within reach of a plain scan.

The 1.4x gap between the flat array and the object array is worth holding onto. It is one extra property access, but it happens once per item, so it compounds. Flattening your key storage is cheaper and more effective than designing an index.

My original decision to reach for an index was made before this table existed. I was working from the feeling that "twenty thousand is a lot."

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦FTS5 trigram silently returns zero for queries under three characters. In my run, 猫 (606 matches), 夜景 (816), and 桜 (1,263) all vanished without an error
✦A linear scan over 20,000 items took 0.80 ms median. Adding an index is only justified once measurements actually breach the frame budget
✦The real bottleneck was startup normalization, not search: 39.5 ms at 20,000 items, cut to 1.1 ms by precomputing keys and shipping them newline-joined
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ Dev Tools2026-04-25
Is a Rork-Generated App Really Lighter? Separating the ML Optimization Rumors From What You Can Measure
Why Rork-generated apps often feel light, split into what can be confirmed and what is only guesswork. Includes a hands-on routine for measuring bundle size, cold start, and list rendering in your own project, plus guardrails for keeping performance after you add hand-written code.
⬡ Dev Tools2026-10-30
It runs in development but the iOS Release build dies on launch — checking whether a missing scheme is the cause
In an expo-router app, an app.json with no scheme can crash only the iOS Release build at launch. Why Debug and Android survive, the two ways to fix it, how to think about leaving the scheme out on purpose, and a pre-submission check.
⬡ Dev Tools2026-10-15
When EXPO_PUBLIC_ Values Read Fine in Dev but Come Back undefined in Production: Telling the Spellings Apart
The API URL reads fine while developing and turns undefined once the app is built. The cause was how process.env was written. I lined up babel-preset-expo's output for dev and production and tabulated which spellings get replaced and which are left behind.