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

Improve search relevance #8

Merged
merged 21 commits into from
Jun 7, 2024
Merged

Improve search relevance #8

merged 21 commits into from
Jun 7, 2024

Conversation

sercancicek
Copy link

@sercancicek sercancicek commented Mar 18, 2024

Description

Problem and Solution

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

Copy link
Collaborator

@matthieucan matthieucan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this looks great! Couple questions:

Copy link
Collaborator

@jochemvandooren jochemvandooren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This improves search so much 🙌

Just some small comments, but it works perfectly!

src/app/main/index.js Outdated Show resolved Hide resolved
src/app/main/index.js Outdated Show resolved Hide resolved
src/app/components/search/search.js Outdated Show resolved Hide resolved
@jochemvandooren
Copy link
Collaborator

I think we are just missing a changelog entry! other than that it looks good 🤩

Copy link
Collaborator

@matthieucan matthieucan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the latest result your exploration of unit-testing this feature?

Copy link
Collaborator

@jochemvandooren jochemvandooren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

FORK.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@matthieucan matthieucan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

FORK.md Outdated Show resolved Hide resolved
@sercancicek sercancicek merged commit c2e5ab6 into fork Jun 7, 2024
@sercancicek sercancicek deleted the scicek/fix-search-results branch June 7, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants