refactor: increase search sensitivity and simplify metadata filtering in FlowSidebarComponent (#4546)
🔧 (traditional-search-metadata.ts): Simplify filtering logic to only consider item metadata for search 🔧 (index.tsx): Adjust search threshold value to improve search accuracy
This commit is contained in:
parent
8e0d6d55de
commit
9c004e7646
2 changed files with 2 additions and 6 deletions
|
|
@ -11,10 +11,7 @@ export const traditionalSearchMetadata = (
|
|||
const filteredItems = Object.fromEntries(
|
||||
Object.entries(items).filter(
|
||||
([key, item]) =>
|
||||
normalizeString(key).includes(searchTerm) ||
|
||||
normalizeString(item.display_name).includes(searchTerm) ||
|
||||
normalizeString(category).includes(searchTerm) ||
|
||||
(item.metadata && searchInMetadata(item.metadata, searchTerm)),
|
||||
item.metadata && searchInMetadata(item.metadata, searchTerm),
|
||||
),
|
||||
);
|
||||
return [category, filteredItems];
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ export function FlowSidebarComponent() {
|
|||
useEffect(() => {
|
||||
const options = {
|
||||
keys: ["display_name", "description", "type", "category"],
|
||||
threshold: 0.3,
|
||||
threshold: 0.2,
|
||||
};
|
||||
|
||||
const fuseData = Object.entries(data).flatMap(([category, items]) =>
|
||||
|
|
@ -171,7 +171,6 @@ export function FlowSidebarComponent() {
|
|||
if (fuse) {
|
||||
const fuseResults = fuse.search(search);
|
||||
setSortedCategories(fuseResults.map((result) => result.item.category));
|
||||
|
||||
combinedResults = combinedResultsFn(fuseResults, data);
|
||||
|
||||
const traditionalResults = traditionalSearchMetadata(data, searchTerm);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue