package org.codelibs.elasticsearch.df.util;

import static org.elasticsearch.common.unit.TimeValue.parseTimeValue;

import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.rest.RestRequest;

public class RequestUtil {
    private RequestUtil() {
    }

    public static TimeValue getScroll(final RestRequest request) {
        final String scroll = request.param("scroll");
        if (scroll != null) {
            return parseTimeValue(scroll, null);
        } else {
            return new TimeValue(60000);
        }
    }

	public static void setScroll(RestRequest request,
			SearchRequestBuilder prepareSearch) {
		if(!disableScroll(request)) {
			prepareSearch.setScroll(RequestUtil.getScroll(request));
		}
	}
	
	public static boolean disableScroll(RestRequest request) {
		return request.paramAsBoolean("from", false) || request.paramAsBoolean("size", false);
	}
}

@@ -896,49 +896,8 @@
 om%22,
- false) %7C%7C request.paramAsBoolean(%22size%22,
  fal

disable scroll using from param