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

Rewrite/redirect '#<topic>' search expressions to 'topic:<topic>' #8227

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

isoos
Copy link
Collaborator

@isoos isoos commented Nov 5, 2024

  • This was mentioned while we have discussed Tracking completion widget issues #8189.
  • We don't actively keep track of the topics, if we want to restrict the rewrite to existing topics, we should probably cache the topic names locally too.

@isoos isoos requested review from jonasfj and sigurdm November 5, 2024 10:27
Copy link
Contributor

@sigurdm sigurdm left a comment

Choose a reason for hiding this comment

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

I don't really worry that the rewrite happens for non-existing topics. That is what I would expect.

My only question is, if the rewrite should go the other way (such that #topic is the canonical version) @szakarias any opinion?

expect(
canonicalizeSearchForm(_parse('#widget #testing'))?.query,
'topic:widget topic:testing',
);
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a test case where I search for "#hash" -- and would that work if I actually want to search for a keyword that starts with # ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

# is by default removed from the content at indexing and from queries (used as a separator).

The end result of this change is that #hash search from https://pub.dev/packages?q=%23hash gets redirected to https://pub.dev/packages?q=topic%3Ahash and yeah, we can add a test for that.

@isoos
Copy link
Collaborator Author

isoos commented Nov 5, 2024

My only question is, if the rewrite should go the other way (such that #topic is the canonical version)

I'm 50:50 on this one. However, going to the other direction would require more change in the query parsing, and we can start with this one first, allowing the use of #, while still reverse the canonicalization at a later point.

@isoos isoos merged commit 7a518f5 into dart-lang:master Nov 5, 2024
32 checks passed
@isoos isoos deleted the search-redirect branch November 5, 2024 17:17
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