I picked a new search provider by counting how many of its ten results were post links. Nine of ten: looked fine. A day after shipping, topic search on Xiaohongshu (RedNote) was coming back empty two times out of three.

This is from LinkDigest, a link-reading tool I build; its search finds posts on a topic and hands back links an agent can read. The numbers are from its own search log and from five real topics replayed on 2026-11-19. Small sample: check it against your own data.

What happened

Searches Found nothing Empty rate
Old provider, three weeks 135 17 12%
New provider, one day 15 10 66%

Every search logs how many results each provider call returned and how many survived filtering. The empty ones read the same way: five calls, ten results each, zero kept.

The metric I used, and why it was wrong

"How many of the returned links are post pages" answers can it find pages on this site. It does not answer are those pages about the topic.

Behind the search sits a relevance filter: every subject word of the query must appear in the title or the excerpt. (For "京都 住宿 攻略", "Kyoto, where to stay, guide", the subjects are Kyoto and lodging; "guide" only says what kind of post.) That filter exists because of earlier off-topic results and is not going away.

Five real topics, both providers, results left after the filter:

Topic New provider Main query back on the old one
Kyoto, where to stay 2 5
First-person cooking vlog 1 4
A professional exam 1 (off topic) 0
Pop-up in a mall atrium 0 1
Corporate catering in Beijing 0 0

The last three are narrow; neither index holds much, and that is the ceiling. The first two differ a lot, and the excerpts say why:

  • The old provider's excerpt is the passage that matched: the note's own sentence about a machiya inn in Kyoto.
  • The new provider's excerpt is the top of the page: * Notifications More Terms of Service Privacy Policy … © 2026 rednote <author> Follow <author> Follow <title> 1/9 …, with the note starting a few hundred characters later. Seven of ten excerpts for one topic began like that.

The provider was finding plenty. My filter was reading menus.

Four things worth copying

1. Measure what is left after your own filter. Word match, embeddings or a model: run it behind the engine when you compare engines. Counting returned links measures nothing you ship.

2. Record once, replay offline. Store each response on disk under a hash of the request. Every later change to the filter or the cleaning runs against the recordings for free. The whole investigation cost under $0.20.

3. Clean the excerpt before matching it, and before showing it. Page furniture ends at a fixed marker (the copyright line), the author row ends in "Follow", and the title is repeated once. Cut those and the first 500 characters are the post. What the user sees as a summary gets better in the same change.

4. Log which call supplied the answer. One search fans out to five calls, and the log only said how many each returned. Once it also said which call each delivered result first came from, the most expensive one turned out to have returned 43 posts over five topics, of which the filter kept two, one of them off topic, for 44% of the search's cost. It is gone.

import hashlib, json, re from pathlib import Path # ---------- 1. On topic: every SUBJECT word of the query is in the title or the excerpt ---------- QUALIFIERS = {"攻略", "推荐", "测评", "教程", "合集", "热门", "探店", "避雷"} # "guide", "review"...: the kind of post, not its subject def subject_terms(query: str) -> list[str]: words = [w for w in re.split(r"[\s,,。、]+", query.strip()) if w] return [w for w in words if w not in QUALIFIERS] or words def has_term(term: str, text: str) -> bool: """Chinese has no spaces: a term matches when any two adjacent characters of it appear.""" if len(term) < 2: return term in text return any(term[i:i + 2] in text for i in range(len(term) - 1)) def on_topic(title: str, excerpt: str, query: str) -> bool: text = f"{title} {excerpt}" return all(has_term(t, text) for t in subject_terms(query)) # ---------- 2. Clean the excerpt: drop the menu, the footer, the author row, the repeated title ---------- FURNITURE_END = re.compile(r"© ?20\d\d(?:-20\d\d)? ?rednote|电话:9501-3888|Law Enforcement Guidelines") AUTHOR_ROW = re.compile(r"^(?:\d+/\d+\s+)?\S{1,30}\s+(?:Follow|关注|フォロー)\s+") SITE_SUFFIX = re.compile(r"(?:\s*[-–|]\s*(?:小红书|rednote))+\s*$", re.I) def tidy_title(title: str) -> str: return SITE_SUFFIX.sub("", title).strip() def note_excerpt(title: str, content: str) -> str: s = re.sub(r"\s+", " ", content).strip() cut = 0 for m in FURNITURE_END.finditer(s[:900]): cut = m.end() s = s[cut:].strip() t = tidy_title(title) for _ in range(3): # author row, the title once more, the picture counter before = s s = AUTHOR_ROW.sub("", s) at = s[:300].rfind(t) if len(t) >= 4 else -1 if at >= 0: s = s[at + len(t):] s = re.sub(r"^\s*\d+/\d+\s+", "", s).strip() if s == before: break return s # ---------- 3. Record once, replay offline: a request is paid for one time ---------- def recorded(call, request: dict, folder: Path, replay_only: bool = False) -> dict: key = hashlib.sha1(json.dumps(request, sort_keys=True, ensure_ascii=False).encode()).hexdigest()[:16] file = folder / f"{key}.json" if file.exists(): return json.loads(file.read_text(encoding="utf-8")) if replay_only: raise LookupError(f"never recorded: {request}") answer = call(request) # the real, billed search call file.write_text(json.dumps(answer, ensure_ascii=False), encoding="utf-8") return answer # ---------- demo ---------- QUERY = "京都 住宿 攻略" # "Kyoto, where to stay, guide" RAW = [ # titles and excerpts in the shapes the two providers returned (shortened) ("日本关西八天下篇 - rednote", "* Notifications More Terms of Service Privacy Policy Your Privacy Choices Law Enforcement Guidelines © 2026 rednote " "小林 Follow 小林 Follow 日本关西八天下篇 1/9 神户退房前往京都。京都住宿选在京都站对面,坐电车公交都方便"), ("🇯🇵京都赏枫全攻略(含住宿推荐 - 小红书", "住进京都老街,每天被枫叶和古都晨光唤醒,这家百年町家改造的日式旅馆不要错过"), ("香港0元能住到什么样的地方? - 小红书", "行吟信息科技(上海)有限公司 地址:上海市黄浦区马当路388号C座 电话:9501-3888 在香港市中心舒服过夜"), ] print("subject terms:", subject_terms(QUERY)) for title, content in RAW: clean = note_excerpt(title, content)[:500] print(f"before: {content[:16]!r:22} after: {clean[:12]!r:18} on topic: {on_topic(tidy_title(title), clean, QUERY)}") calls = [] def fake_api(request): # stands in for the search API calls.append(request) return {"results": [{"title": t, "content": c} for t, c in RAW]} folder = Path("rec"); folder.mkdir(exist_ok=True) for f in folder.glob("*.json"): f.unlink() request = {"engine": "demo", "q": QUERY, "max_results": 10} recorded(fake_api, request, folder) # first time: a real call recorded(fake_api, request, folder) # second time: read from disk recorded(fake_api, request, folder, replay_only=True) # offline: a call would raise print("real calls:", len(calls), "| recordings on disk:", len(list(folder.glob("*.json")))) 

Output:

subject terms: ['京都', '住宿'] before: '* Notifications ' after: '神户退房前往京都。京都住' on topic: True before: '住进京都老街,每天被枫叶和古都晨' after: '住进京都老街,每天被枫叶' on topic: True before: '行吟信息科技(上海)有限公司 地' after: '在香港市中心舒服过夜' on topic: False real calls: 1 | recordings on disk: 1 

One thing I tried and did not ship

Letting a small model decide "is this result about the topic" instead of matching words. For the cooking-vlog topic it kept ten results, five of them restaurant visits. A filter that lets off-topic results in is worse than none.

The fix

The main query went back to the provider that returns the matched passage, one call per search instead of four (four per search is how the monthly allowance had run out). The keyword variants stayed on the cheaper engine. Excerpts are cleaned first. Post addresses with a language prefix (/zh/…) are no longer discarded as "not a post". Checked live on the same topic: two results before, five on-topic results in 3.3 seconds after.

Short version

  • Judge a search API by results that are useful after your filter, not by links returned.
  • Record responses and replay them; changing code should not cost money.
  • An excerpt may be the top of the page and not the matching passage. Look at one raw response before trusting the field.
  • Make the log able to answer "which call earns its cost".