Search Experience Review
发布时间 2023-10-18 03:10:00 # 前端实践

This note comes from a typical on-site search improvement task. The problem was not complicated, but the impact was obvious: users could technically find content, yet the experience still felt slow and inaccurate.

Symptoms

  • The first search overlay open had a visible delay
  • Result snippets were abrupt and keyword matches were hard to notice
  • Entering two keywords reduced result count too aggressively

Approach

We did not add any extra service and kept the local search.xml flow. The optimization focused on only three things:

  1. Load the index file only when the search overlay is actually opened
  2. Show shorter snippets while typing to reduce cognitive load
  3. Highlight matched keywords to reduce the feeling that nothing was found

Acceptance Criteria

Metric Before After
Time to first usable search ~2.3s ~1.2s
Result snippet length Inconsistent Around 100 characters
Common keyword hit rate Fair Stable

Implementation Note

One detail mattered a lot: do not fetch the full search index during the initial homepage render. The difference is small on a tiny demo site, but it becomes obvious on a real content-heavy site.

1
2
3
function shouldLoadSearchIndex(isOpen, loaded) {
return isOpen && !loaded
}

Conclusion

Search does not get better just because it becomes more complex. On a static site like this, getting load timing, keyword highlighting, and snippet extraction right usually delivers a noticeable improvement on its own.

Prev
2023-10-19 09:45:00
Next