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

ElasticPress limits the number of WooCommerce products in category #1656

Closed
roditi3811 opened this issue Feb 7, 2020 · 5 comments
Closed
Labels

Comments

@roditi3811
Copy link

Describe the bug
When I enable ElasticPress in my WooCommerce store, the number of products listed are limited to 10000.
With the ElasticPress plugin disabled, I get the correct number of products from the category (313851).
I'm not sure if it's a problem from ElasticPress or maybe ElasticSearch?

Steps to Reproduce

  1. Click on any category with more than 10000 products.
  2. See error

Screenshots
EP

Additional context
Tried tweaking search.max_buckets: 100000 or even 1000000 but with no success.

What could be the problem?

@brandwaffle
Copy link
Contributor

@roditi3811 you can increase the value of

$posts_per_page = apply_filters( 'ep_max_results_window', 10000 );
up to 1,000,000 (that's the index.max_result_window set by the plugin) and you'll get the updated total of results. It's just another default setting we build in to handle performance. You might check out the scroll API referenced in the code comment above that filter, but based on your previous ticket your Elasticsearch instance might just be large enough to handle the window change 😄

@roditi3811
Copy link
Author

Thank for the reply, but it doesn't seem to change anything, I'm still getting 10000 results :(
image

Also I've tried
curl -XPUT "http://XXX:9200/XXX-post-1/_settings" -H 'Content-Type: application/json' -d '{ "index" : { "max_result_window" : 10000000 } }'
And the results of http://XXX:9200/XXX-post-1/_settings
image

I'm not sure if it means something, but the first time when I am accessing the category, I see the correct number of products.
If I make a search for a general term and I hit the 10000 limit, when I go back and access that category again, I see the limit of 10000 there also, as if it applies the search limit to the categories also.

@jakubkol
Copy link

What is your ElasticSearch version? From version 7.0 is track_total_hits set to 10000 by default: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#track-total-hits-10000-default

You can force it like this:

add_filter( 'ep_formatted_args', function ( $formatted_args ) {
   $formatted_args['track_total_hits'] = true;
   return $formatted_args;
} );

@roditi3811
Copy link
Author

add_filter( 'ep_formatted_args', function ( $formatted_args ) {
$formatted_args['track_total_hits'] = true;
return $formatted_args;
} );

PERFECT! That did the job indeed, thanks very much, works like a charm now.
Elasticsearch version is 7.5.2

@humblearab
Copy link

Cheers.

This resolved an error of my site too, and man have I been going around in circles.

What is your ElasticSearch version? From version 7.0 is track_total_hits set to 10000 by default: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#track-total-hits-10000-default

You can force it like this:

add_filter( 'ep_formatted_args', function ( $formatted_args ) {
   $formatted_args['track_total_hits'] = true;
   return $formatted_args;
} );

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

No branches or pull requests

4 participants