Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritise exact file name matches over fuzzy matches #503

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sercancicek
Copy link

@sercancicek sercancicek commented Mar 20, 2024

Resolves #217

Description

Problems and Solutions

The assignSearchRelevance function goes through each result object and assigns a score based on certain criteria, using the following formula:

        let criteriaArr = {
            "name": 10,
            "tags": 5,
            "description": 3,
            "raw_code": 2,
            "columns": 1
        };
result.overallWeight += (count * criteriaArr[criteria]);

Although this method is effective, it introduces a problem. For example, when searching for the term dm_test in the data below, the entry dm_test_total ends up with a score of 19 (10 points from name + 9 points from description), while dm_test gets only 10 points.

name description
dm_test Test dm
dm_test_total Sums dm_test, multiplies dm_test, calculates dm_test

To fix this, the pull request adds an additional step to the relevance calculation process. Now, a weight value is also computed and stored for the name field. Finally, the results are sorted first by overallNameWeight and then by overallWeight.

Checklist

@sercancicek sercancicek force-pushed the scicek/feat-217-search branch from fe8d075 to 8f45de7 Compare June 10, 2024 09:12
@cla-bot cla-bot bot added the cla:yes label Jun 10, 2024
Copy link
Contributor

github-actions bot commented Dec 8, 2024

This PR has been marked as Stale because it has been open with no activity as of late. If you would like the PR to remain open, please comment on the PR or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes community This PR is from a community member Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Search bar should prioritise exact file name matches over fuzzy matches
2 participants