Every data source — JSON Config, Auto-Discovery, Sitemap — feeds items into the same index. This page covers what happens after that: how a query matches items, how results are ranked, and how to keep specific items or fields out of the index entirely. The model follows the same shape as cmdk's filter prop, if you've used that before.
By default, Slash scores each item by fuzzy-matching the query against its label, keywords, and category, with label matches weighted highest. Pass a custom filter function to replace this entirely — it receives the item and the current query, and returns a number from 0 (no match, excluded from results) to 1 (perfect match).
123456789101112import { Slash } from '@slash.tools/react'
function filter(item: SlashItem, query: string) { const q = query.toLowerCase() if (item.label.toLowerCase().startsWith(q)) return 1 if (item.keywords?.some((k) => k.toLowerCase().includes(q))) return 0.6 return 0}
export function App() { return <Slash apiKey={process.env.SLASH_API_KEY} filter={filter} />}Field weighting is available without writing a full custom filter, for the common case of just wanting to nudge which fields matter more.
1234<Slash apiKey={process.env.SLASH_API_KEY} weights={{ label: 1, keywords: 0.6, category: 0.3 }}/>If you're driving results from your own server — hitting a search API on every keystroke rather than filtering a local index — disable Slash's built-in matching with shouldFilter={false} and pass back items already in the order you want them shown.
123456<Slash apiKey={process.env.SLASH_API_KEY} shouldFilter={false} items={serverResults} onQueryChange={(query) => fetchResults(query).then(setServerResults)}/>To keep certain items out of the index without removing them from a data source you don't control directly — like Auto-Discovery picking up a link you'd rather not surface — use exclude with a predicate or a list of URLs.
1234<Slash apiKey={process.env.SLASH_API_KEY} exclude={(item) => item.url?.startsWith('/admin')}/>Stop words and synonyms adjust matching without touching individual items — useful for filler terms you never want to match on, or for aliasing internal naming to what users actually search for.
12345<Slash apiKey={process.env.SLASH_API_KEY} stopWords={['the', 'a', 'page']} synonyms={{ signin: ['login', 'log in', 'sign in'], settings: ['preferences', 'config'] }}/>Finally, control when the index itself gets rebuilt with reindex. The default, "route-change", re-scans Auto-Discovery sources on every navigation and leaves JSON Config and Sitemap items untouched between page loads. Set it to "interval" to periodically refetch all sources, or "manual" to only rebuild when you call the index's refresh method yourself.
123456const slashRef = useRef<SlashHandle>(null)
<Slash ref={slashRef} apiKey={process.env.SLASH_API_KEY} reindex="manual" />
// later, after your own data changesslashRef.current?.refresh()filter(item, query) => numberFull control over match scoring. Replaces the default entirely.weightsRecord<string, number>Tune built-in field weighting without a custom filter.shouldFilterbooleanDisable built-in matching for server-driven or async results. Defaults to true.exclude(item) => boolean | string[]Keep specific items out of the index by predicate or URL list.stopWordsstring[]Terms ignored when matching, so they never affect scoring.synonymsRecord<string, string[]>Aliases a term to match any of a list of alternates.reindex"route-change" | "interval" | "manual"Controls when the index is rebuilt. Defaults to "route-change".