dbt-labs / dbt-docs

Auto-generated data documentation site for dbt projects
Apache License 2.0
139 stars 74 forks source link

Prioritise exact file name matches over fuzzy matches #502

Closed sercancicek closed 5 months ago

sercancicek commented 5 months ago

Resolves #217

Description

Problems and Solutions

  1. In the search.js file, the variable scope.results is both used and modified, which leads to issues. It operates on the same object that was initialized in the main/index.js file (scope). This modification causes the loss of relevance value because the parent scope computes a relevance value and assigns it. The solution was to use different variable names, as implemented in the pull request.
            scope.$watchGroup(watchExpressions, function() {
                scope.results = filterResults(scope.results, scope.checkboxStatus);
            });
  1. 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

cla-bot[bot] commented 5 months ago

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: sercancicek. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails
cla-bot[bot] commented 5 months ago

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: sercancicek. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails
sercancicek commented 5 months ago

Closed because of commit's email addr problems