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

[Type] Enhancement : post higher priority in link search results #63836

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

kartikmehta8
Copy link

What?

This PR updates the sortResults function in the link suggestions feature to prioritize pages and posts above attachments in search results.

Why?

Attachments were being surfaced higher in search results than posts matching the search requirements. This change ensures that pages and posts are prioritized in the search results, which is more likely to be the desired outcome for users.

How?

The sortResults function has been updated to add a score increment for results that are of kind post-type and type post or page. This adjustment ensures that these types of results are prioritized above others, such as attachments.

Testing Instructions

  1. Open a post or page.
  2. Use the link control to search for content.
  3. Observe that pages and posts are prioritized in the search results over attachments.

Testing Instructions for Keyboard

  1. Open a post or page using keyboard navigation.
  2. Use the link control to search for content using keyboard navigation.
  3. Ensure that pages and posts are prioritized in the search results over attachments.

Issue

Screenshots or screencast

N/A

@kartikmehta8 kartikmehta8 requested a review from nerrad as a code owner July 23, 2024 06:47
Copy link

github-actions bot commented Jul 23, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @coenve.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: coenve.

Co-authored-by: kartikmehta8 <kartikmehta@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: noisysocks <noisysocks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @kartikmehta8! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 23, 2024
@kartikmehta8 kartikmehta8 changed the title fix: post higher priority in link search results [Type] Enhancement : post higher priority in link search results Jul 23, 2024
@talldan talldan requested a review from noisysocks July 23, 2024 07:04
@talldan
Copy link
Contributor

talldan commented Jul 23, 2024

I think @noisysocks worked on this recently, so might have some thoughts. Hope you don't mind that I added you as a reviewer, Rob!

@talldan talldan added [Type] Enhancement A suggestion for improvement. [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels Jul 23, 2024
@noisysocks
Copy link
Member

Hey thanks for the PR!

I haven't tested it but I suspect this approach will cause a regression of #56478 if there are more than 20 posts or pages on the site containing the search term. This is because all twenty of those posts and pages will receive a score of 1 (the base score this PR adds) regardless of their relevancy and crowd out any categories and tags even if they are an exact match (score = 1).

We want to prioritise posts and pages but not so much that they crowd out attachments, tags, and categories that are very relevant to the search query.

How did you arrive at 1 as a base score for posts and pages? I expect the solution will be to change this to 0.5 or thereabouts. The exact number will need to be dialled in from testing with real data. The testing steps in #62397 describe how you can set yourself up with testing data that is good for working on this feature.

@coenve
Copy link

coenve commented Dec 2, 2024

Ever since Wordpress added the score element to the link suggestions, my editors have been complaining about tags and attachments coming up first instead of relevant blogs they would like to link to. They find it very annoying that the sort order was changed. They asked me if I could undo that change.

Since I don't want to mess around in the source code, is there a filter I can use to manually override the search order?

My opinion on this case is:
Only show tags, categories, and attachments that match the keyword for 100%. If it's 99% don't show it. Go for posts and pages first.

We run a technology blog with tens of thousands of blogs. For example we write a lot about Microsoft, we have a few dozen Microsoft tags. If an author now wants to link to a recent Microsoft blog it's hard, because there are too many tags that start with Microsoft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants