Cannot get date math to work properly in Elasticsearch

Hi Alex,

Apologies for the delay, I was traveling last week. Below is the simple PHP script I'm using to import the data, using the official ES client for PHP. When I try this from scratch with a new index, with the script below, I get many dates that fall outside the 7 day window. Can you try it in your environment and see if you get the same result?

<?php
use Elasticsearch\ClientBuilder;
require 'vendor/autoload.php';
date_default_timezone_set('UTC');
$hosts = ['<insert ES host>'];
$client = Elasticsearch\ClientBuilder::create()           // Instantiate a new ClientBuilder
                    ->setHosts($hosts)      // Set the hosts
                    ->build();              // Build the client object
$dateArray = json_decode(file_get_contents("dateData.json"), true);
$elasticOutput = "";
$elasticRecordCount = 0;
$i = 0;
foreach($dateArray as $row){
    $params['body'][] = [
        'index' => [
            '_index' => 'date_test'
	]
    ];
    $params['body'][] = $row;
	// Every 1000 documents stop and send the bulk request
    if ($i % 1000 == 0) {
        $responses = $client->bulk($params);
		if (isset($responses['errors']) === true && $responses['errors'] === true) {
			$elasticOutput .= "There was one or more errors in the bulk response.".$responses['errors'];
		}else{
			$elasticRecordCount += sizeof($responses['items']);
		}
        // erase the old bulk request
        $params = ['body' => []];
        // unset the bulk response when you are done to save memory
        unset($responses);
    }
	$i += 1;
}
// Send the last batch if it exists
if (!empty($params['body'])) {
    $responses = $client->bulk($params);
	if (isset($responses['errors']) === true && $responses['errors'] === true) {
		$elasticOutput .= "There was one or more errors in the bulk response.".$responses['errors'];
	}else{
		$elasticRecordCount += sizeof($responses['items']);
	}
}
echo ", Elastic Records Indexed: $elasticRecordCount (errors: $elasticOutput)";
?>