Core: Check if from + size don't cause overflow and fail with a better error

I agree that is a better message, I'll update.

On 18 September 2014 16:05, Simon Willnauer <notifications@github.com>
wrote:

> In
> src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java:
>
> > @@ -213,6 +214,14 @@ public void doClose() throws ElasticsearchException {
> >       * Should be called before executing the main query and after all other parameters have been set.
> >       */
> >      public void preProcess() {
> > +        if (!(from() == -1 && size() == -1)) {
> > +            // from and size have been set.
> > +            int numHits = from() + size();
> > +            if (numHits < 0) {
> > +                throw new QueryPhaseExecutionException(this, "From and size combined can't be negative");
>
> I think we should return a readable / understandable msg here something
> like:
>
> QueryPhaseExecutionException("Result window is too large, from+size must be less than or equal to: [" + Integer.MAX_VALUE + "] but was [" + (((long)from()) + ((long)size()))) + "]";
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/elasticsearch/elasticsearch/pull/7778/files#r17728419>
> .
>



-- 
Met vriendelijke groet,

Martijn van Groningen