Commit ee42a81a authored by LongLD's avatar LongLD

fix: ensure global rules appear in tag-filtered searches

parent a03fec9f
......@@ -91,8 +91,14 @@ export class Scorer {
calculateTagScore(rule, queryTags) {
if (!queryTags || queryTags.length === 0)
return 0;
// Global rules always get partial tag score even without matching tags
const isGlobalRule = rule.tags.includes('global') || rule.tags.includes('base') || rule.id.includes('base');
const intersection = rule.tags.filter(t => queryTags.includes(t));
return intersection.length > 0 ? Math.min(1, intersection.length / queryTags.length) : 0;
if (intersection.length > 0) {
return Math.min(1, intersection.length / queryTags.length);
}
// Give global rules a small positive score to ensure they appear in filtered results
return isGlobalRule ? 0.3 : 0;
}
calculatePriorityScore(rule) {
return (rule.priority || 50) / 100;
......
......@@ -110,8 +110,17 @@ export class Scorer {
private calculateTagScore(rule: Rule, queryTags: string[]): number {
if (!queryTags || queryTags.length === 0) return 0;
// Global rules always get partial tag score even without matching tags
const isGlobalRule = rule.tags.includes('global') || rule.tags.includes('base') || rule.id.includes('base');
const intersection = rule.tags.filter(t => queryTags.includes(t));
return intersection.length > 0 ? Math.min(1, intersection.length / queryTags.length) : 0;
if (intersection.length > 0) {
return Math.min(1, intersection.length / queryTags.length);
}
// Give global rules a small positive score to ensure they appear in filtered results
return isGlobalRule ? 0.3 : 0;
}
private calculatePriorityScore(rule: Rule): number {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment