Skip to content

Refactor search ranking #3424

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

Merged
merged 2 commits into from
May 30, 2023
Merged

Refactor search ranking #3424

merged 2 commits into from
May 30, 2023

Conversation

srawlins
Copy link
Member

A few items of note:

  • Move search filtering and ranking to lib/ and add rudimentary tests. (work towards search UI redux #3419)
  • Switch from a system of "scores" where each result gets an independent score to a system of ranks where results are definitely ordered amongst each other. Under the scores system, it was hard to know in what order results would ultimately be shown.
  • Prefer same-named elements in higher-ranked packages to lower-ranked packages, as per the --package-order flag. (work towards Search results rankings are not always what I'd expect #3176)
  • Remove sort ranking differentiating by case (preferring case-sensitive matches to case-insensitive matches).

@srawlins srawlins requested review from devoncarew and jcollins-g May 30, 2023 15:28
Copy link
Contributor

@jcollins-g jcollins-g left a comment

Choose a reason for hiding this comment

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

nits only. Nice!

final String name;
final String qualifiedName;

// TODO(srawlins): Store the integer of in the package order instead of this
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the index of the package in package order or similar

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Done

// "name":"dartdoc",
// "qualifiedName":"dartdoc",
// "href":"dartdoc/dartdoc-library.html",
// "type":"library",
Copy link
Contributor

Choose a reason for hiding this comment

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

this might be a field that could be crushed into an integer too, if needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it would be nice. We actually display the "type" in the search result so we would have to store the "type" as an int (rather convert to a scope), but yes still savings.

// ```dart
// {
// "name":"dartdoc",
// "qualifiedName":"dartdoc",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: example as "libName.variableName" might be better?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

);
}

int get _scope =>
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment explaining this would be nice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, done! And added a TODO, as its not well-tested.

@srawlins srawlins merged commit ef55299 into dart-lang:main May 30, 2023
@srawlins srawlins deleted the refactor-search branch May 30, 2023 16:49
Copy link
Member

@devoncarew devoncarew left a comment

Choose a reason for hiding this comment

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

Very cool!

}

@reflectiveTest
class SearchTest {
Copy link
Member

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants