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(
|
const filteredItems = Object.fromEntries(
|
||||||
Object.entries(items).filter(
|
Object.entries(items).filter(
|
||||||
([key, item]) =>
|
([key, item]) =>
|
||||||
normalizeString(key).includes(searchTerm) ||
|
item.metadata && searchInMetadata(item.metadata, searchTerm),
|
||||||
normalizeString(item.display_name).includes(searchTerm) ||
|
|
||||||
normalizeString(category).includes(searchTerm) ||
|
|
||||||
(item.metadata && searchInMetadata(item.metadata, searchTerm)),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return [category, filteredItems];
|
return [category, filteredItems];
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ export function FlowSidebarComponent() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const options = {
|
const options = {
|
||||||
keys: ["display_name", "description", "type", "category"],
|
keys: ["display_name", "description", "type", "category"],
|
||||||
threshold: 0.3,
|
threshold: 0.2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const fuseData = Object.entries(data).flatMap(([category, items]) =>
|
const fuseData = Object.entries(data).flatMap(([category, items]) =>
|
||||||
|
|
@ -171,7 +171,6 @@ export function FlowSidebarComponent() {
|
||||||
if (fuse) {
|
if (fuse) {
|
||||||
const fuseResults = fuse.search(search);
|
const fuseResults = fuse.search(search);
|
||||||
setSortedCategories(fuseResults.map((result) => result.item.category));
|
setSortedCategories(fuseResults.map((result) => result.item.category));
|
||||||
|
|
||||||
combinedResults = combinedResultsFn(fuseResults, data);
|
combinedResults = combinedResultsFn(fuseResults, data);
|
||||||
|
|
||||||
const traditionalResults = traditionalSearchMetadata(data, searchTerm);
|
const traditionalResults = traditionalSearchMetadata(data, searchTerm);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue