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

Add an option to limit results with Elastica #213

Merged
merged 1 commit into from
May 17, 2018

Conversation

odolbeau
Copy link
Contributor

@odolbeau odolbeau commented Oct 2, 2016

With recent ES version, we have en exception when size + offset > 10000.
BTW it's possible to override this directly in ES configuration even if it's not recommended.

With this new constructor argument, it's possible to limit the number of results even if the dataset contains more results.
In this case, we won't display pages where size + offset > 10000 and we won't have this error:

 * [2016-09-24 12:20:12] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Result window is too large, from + size must be less than or equal to: [10000] but was [33920]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level parameter. [reason: all shards failed]") in "***" at line X."

@sampart
Copy link
Collaborator

sampart commented May 1, 2018

Thank for this, @odolbeau. I'm sorry there's been no activity from us here. Please could you add something to the Elastica section in the README explaining this new option? This will then be good to merge, I think.

@odolbeau
Copy link
Contributor Author

PR rebased! 👍

Copy link
Collaborator

@sampart sampart left a comment

Choose a reason for hiding this comment

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

Thanks for this. Just one last change.

README.md Outdated
@@ -294,6 +294,10 @@ $query = new Query::create(new Term(array(
$adapter = new ElasticaAdapter($searchable, $query);
```

*Be careful when paginating a huge set of documents. By default, offset + limit
can't exceed 10000. For more information, see:
[#213](https://github.com/whiteoctober/Pagerfanta/pull/213#issue-87631892).*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add an additional sentence saying something like "You can mitigate this by setting the $maxResults parameter when constructing the ElasticaAdapter"? Thanks

@odolbeau
Copy link
Contributor Author

Done

Copy link
Collaborator

@sampart sampart left a comment

Choose a reason for hiding this comment

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

Perfect, thanks.

@sampart
Copy link
Collaborator

sampart commented May 17, 2018

I'll merge once tests have passed.

@sampart sampart merged commit 15770d9 into whiteoctober:master May 17, 2018
@sampart
Copy link
Collaborator

sampart commented May 17, 2018

I've created release https://github.com/whiteoctober/Pagerfanta/releases/tag/v2.0.1 for this. Thanks again for your input.

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.

None yet

2 participants