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

Plugins: Modify search results total when there are more than 1000 results #310

Closed
ndiego opened this issue May 8, 2024 · 6 comments
Closed
Labels
[Site] Plugins [Status] Needs Design Feedback Feedback is needed on an existing or new component [Type] Enhancement New feature or request

Comments

@ndiego
Copy link
Member

ndiego commented May 8, 2024

When searching in the Plugin Directory, the maximum number of returned search results is 1020. Because many search terms return 1020 results, and the number is so specific, it feels odd or that something is not working correctly. If the search maxes out at 1020, I propose we instead display 1,000+.

Current Proposed
image image
@ndiego ndiego added [Type] Enhancement New feature or request [Site] Plugins [Status] Needs Design Feedback Feedback is needed on an existing or new component labels May 8, 2024
@pkevan
Copy link
Contributor

pkevan commented May 9, 2024

It should be possible to return the total from ES, even if it isn't possible to paginate through all the results, as the total exists in the response. That would probably be better?

@ndiego
Copy link
Member Author

ndiego commented May 9, 2024

It should be possible to return the total from ES, even if it isn't possible to paginate through all the results, as the total exists in the response. That would probably be better?

Oh yeah, that would be better. Didn't think it was possible.

@dd32
Copy link
Member

dd32 commented May 10, 2024

test search is 5,552 results, as reported by the search api.

1,020 is 51 * 21, the display is limited to 50 pages which would be 1,000, so it seems that there's an off-by-one in the pagination limiting code.

There's a logged-out 50 page limit plugin: https://github.com/WordPress/wordpress.org/blob/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-page-limiter.php

The plugin directory search limits it to 50 pages, which seems odd:

/**
* Limit the number of pagination links to 50.
*
* Jetpack ignores the `max_num_pages` that's set in `WP_Query` args and overrides it in
* `Classic_Search::filter__posts_pre_query()`. When there are more than 1,000 matches, their value causes
* Core's `paginate_links()` to generated 51 links, even though we redirect the user to the homepage when
* page 51+ is requested.
*/
function set_max_num_pages( $posts, $query ) {
$post_type = (array) $query->query_vars['post_type'] ?? '';
if ( is_admin() || ! is_search() || ! in_array( 'plugin', $post_type ) ) {
return $posts;
}
if ( $query->max_num_pages > 50 ) {
$query->max_num_pages = 50;
}
return $posts;
}

Disabling that leads to 51 pages being offered, the 1,020.
So I guess the actual bug is in the upstream Jetpack code that sets it as 1020..

Let's see if this following change works to properly show the search result counter.

bazza pushed a commit that referenced this issue May 10, 2024
… results, rather than capping out at 1020.

See #310


git-svn-id: https://meta.svn.wordpress.org/sites/trunk@13687 74240141-8908-4e6f-9713-ba540dce6ec7
@pkevan
Copy link
Contributor

pkevan commented May 10, 2024

Looks like the numbers are accurately reflected in the search results from a few tests.

I wonder if we should consider a page that exists after 50 pages, something along the lines of "Please consider narrowing your search, results are limited to 1000"?

@ndiego
Copy link
Member Author

ndiego commented May 10, 2024

Let's see if this following change works to properly show the search result counter.

Looks like it's now showing the actual number of plugins 🙌

image

@StevenDufresne
Copy link
Contributor

Can we close this issue now?

@dd32 dd32 closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Site] Plugins [Status] Needs Design Feedback Feedback is needed on an existing or new component [Type] Enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

4 participants