mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
✨ Introducing position-based weight calculation
This commit is contained in:
parent
006e7a07a6
commit
e4998dab7e
|
@ -236,7 +236,14 @@ export function sublimeSearch<T extends object>(
|
||||||
keys.forEach(({ key, weight }) => {
|
keys.forEach(({ key, weight }) => {
|
||||||
const value = getValue(item, key);
|
const value = getValue(item, key);
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
values = values.concat(value.map((v) => ({ value: v, weight })));
|
// Reduce the weight by 10% for subsequent value in the array so we promote results based on the order of values
|
||||||
|
// e.g. if node has multiple aliases, we want to promote the first alias over the second
|
||||||
|
values = values.concat(
|
||||||
|
value.map((v, i) => ({
|
||||||
|
value: v,
|
||||||
|
weight: i <= 1 ? weight : weight * (1 - (i - 1) * 0.1),
|
||||||
|
})),
|
||||||
|
);
|
||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
values.push({
|
values.push({
|
||||||
value,
|
value,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"alias": ["cpde", "Javascript", "JS", "Python", "Script", "Custom Code", "Function"],
|
"alias": ["cpde", "Function", "Javascript", "JS", "Python", "Script", "Custom Code"],
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": ["Helpers", "Data Transformation"]
|
"Core Nodes": ["Helpers", "Data Transformation"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue