Skip to content

Commit 37eff57

Browse files
authored
support ID filtering on indexes (#210)
1 parent 3cbe691 commit 37eff57

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/viewer/src/constants.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ export const sentryIngest =
2525

2626
// Used for Fuse searches
2727
export const searchWeights = {
28+
id: 3,
2829
name: 1,
2930
aliases: 0.7,
3031
description: 0.3,
3132
}
3233
export const searchKeys = [
33-
{ name: 'id', weight: 3, getFn: (s: any) => `${s.id}` },
34-
{ name: 'name', weight: 1 },
35-
{ name: 'aliases', weight: 0.7 },
36-
{ name: 'description', weight: 0.3 },
34+
{ name: 'id', weight: searchWeights.id, getFn: (s: any) => `${s.id}` },
35+
{ name: 'name', weight: searchWeights.name },
36+
{ name: 'aliases', weight: searchWeights.aliases },
37+
{ name: 'description', weight: searchWeights.description },
3738
]
3839
export const searchThreshold = 0.3

packages/viewer/src/stores/list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Fuse from 'fuse.js'
22
import { type Readable, type Writable, derived, writable } from 'svelte/store'
33

4-
import { searchThreshold } from '@/constants'
4+
import { searchKeys, searchThreshold } from '@/constants'
55

66
import * as sort from './sort'
77

@@ -25,6 +25,7 @@ export default function list<T>(
2525
const keys = Object.entries(weights).map(([name, weight]) => ({
2626
name,
2727
weight: (weight as number) || 0,
28+
getFn: searchKeys.find(o => o.name === name)?.getFn,
2829
}))
2930
const index = derived(
3031
collection,

0 commit comments

Comments
 (0)