본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)29k · #9816

fuzzy-ranking

하는 일

이 스킬은 사람들이 짧거나 일부만 입력한 검색어와 얼마나 맞는지 점수를 매기고 걸러 내는 방법을 설명합니다. 목록이나 표에 검색을 추가하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓사람들이 이름의 일부만 입력해도 검색 상자가 항목을 찾아야 할 때.
  • ✓검색 결과를 검색어와 얼마나 가까운지에 따라 정렬하고 싶을 때.
  • ✓TanStack Table 열에 퍼지 검색 필터를 추가하는 경우.

스킬 링크

https://github.com/TanStack/table/blob/main/packages/match-sorter-utils/skills/fuzzy-ranking/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/TanStack/table/blob/main/packages/match-sorter-utils/skills/fuzzy-ranking/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“사람들이 고객 이름의 일부만 입력해도 검색 상자가 찾도록 하고 싶어요. 결과 순위는 어떻게 매기나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

각 항목을 검색어와 비교해 점수를 매기고, 기준치를 넘는 항목만 남긴 뒤, 일치 점수로 정렬하는 방법을 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Setup

<!-- skill-snippet:check -->
import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils'

const query = 'tan'
const values = ['table', 'tanner', 'router']
export const ranked = values
  .map((value) => ({
    value,
    info: rankItem(value, query, { threshold: rankings.MATCHES }),
  }))
  .filter((entry) => entry.info.passed)
  .sort((a, b) => compareItems(a.info, b.info))

Core Patterns

Separate ranking, filtering, and sorting

Call rankItem once, filter on info.passed, retain the RankingInfo, then order matching results with compareItems.

Rank object fields through accessors

type Person = { name: string; email: string }
const person: Person = { name: 'Ada Lovelace', email: 'ada@example.test' }
const info = rankItem(person, 'lov', {
  accessors: [(item) => item.name, (item) => item.email],
})

Accessor options can set a per-accessor threshold plus minRanking/maxRanking bounds.

Store ranking as Table filter metadata

In a Table filterFn, call addMeta?.({ itemRank }). Register the corresponding meta shape with filterMeta: metaHelper<{ itemRank: RankingInfo }>(). A related sortFn reads row.columnFiltersMeta[columnId]?.itemRank and uses compareItems, falling back to an ordinary comparator for ties or absent metadata. For the primary Table composition, load @tanstack/table-core#table-features and read its global-filtering reference. Register the fuzzy filter under filterFns for globalFilterFn: 'fuzzy'.

Common Mistakes

HIGH Numeric rank used as pass flag

Wrong: if (rankItem(value, query).rank) include(value).

Correct: test rankItem(value, query).passed.

Ranks below the configured threshold can still be nonzero; passed records the threshold decision.

Source: TanStack/table:packages/match-sorter-utils/src/index.ts

HIGH Ranking recomputed during sorting

Wrong: call rankItem for both rows on every comparator invocation.

Correct: retain RankingInfo during filtering and pass the stored values to compareItems.

Sorting is called many times; recomputing also risks using different query/options than the filter decision.

Source: TanStack/table:docs/framework/react/guide/fuzzy-filtering.md

MEDIUM compareItems direction reversed twice

Wrong: negate compareItems(a, b) because a larger rank should appear first.

Correct: use compareItems(a, b) directly for ascending fuzzy relevance.

The function already returns -1 when a.rank is greater than b.rank.

Source: TanStack/table:packages/match-sorter-utils/src/index.ts

API Discovery

Inspect node_modules/@tanstack/match-sorter-utils/dist/index.d.ts for the installed RankItemOptions, accessor attributes, ranking constants, and comparator behavior. For TanStack Table metadata integration, load @tanstack/table-core#table-features and read its global-filtering and sorting references.

자주 묻는 질문

한 객체의 여러 필드에서 검색할 수 있나요?

네, 이 스킬은 순위 매기기가 둘 이상의 필드를 확인하도록 하는 접근자를 설명합니다.

기준치는 무엇을 하나요?

항목이 결과에 남으려면 검색어와 얼마나 가까워야 하는지를 정합니다.

순위를 표 필터 데이터로 저장할 수 있나요?

네, 순위를 필터 메타데이터로 저장하고 그것으로 정렬하는 방법을 설명합니다.

상세 정보

작성자의 원본 설명

Rank fuzzy matches with rankItem, filter with RankingInfo.passed, compare saved ranking metadata with compareItems, and configure rankings, thresholds, accessors, min/max bounds, or diacritics. Load for @tanstack/match-sorter-utils itself or fuzzy Table filterMeta wiring.

repo: TanStack/table

인기도

GitHub 스타
29k
순위
#9816
라이선스
MIT
업데이트
2026. 10. 21.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬