code: @SuppressWarnings("unchecked")
    public Query limit(int limit) {
      if (limit < 0) {
        throw new IllegalArgumentException(format("Limit of %d is negative.", limit));
      }
  
      if (limit > MAX_LIMIT) {
        throw new IllegalArgumentException(
            format("Limit of %d is greater than %d.", limit, MAX_LIMIT)
        );
      }
  
      params.put(PARAMETER_LIMIT, Integer.toString(limit));
  
      return (Query) this;
    }
docs: Limits the amount of elements to a given number.
  <p>
  If more then the number given elements are present, you can use {@link #skip(int)} and
  this method for pagination.
  
  @param limit a non negative number less than 1001 to include elements.
  @return the calling query for chaining.
  @see #skip(int)