<p dir="auto">newbie to ES.<br>
This does not return any docs:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  &quot;query&quot;: {
    &quot;filtered&quot;: {
      &quot;query&quot;: {
        &quot;match_all&quot;: {}
      },
      &quot;filter&quot;: {
        &quot;range&quot;: {
          &quot;screened&quot;: {
            &quot;from&quot;: &quot;now-3d&quot;,
            &quot;to&quot;: &quot;now+3d&quot;
          }
        }
      }
    }
  }"><pre class="notranslate">  <span class="pl-ent">"query"</span>: {
    <span class="pl-ent">"filtered"</span>: {
      <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match_all"</span>: {}
      },
      <span class="pl-ent">"filter"</span>: {
        <span class="pl-ent">"range"</span>: {
          <span class="pl-ent">"screened"</span>: {
            <span class="pl-ent">"from"</span>: <span class="pl-s"><span class="pl-pds">"</span>now-3d<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"to"</span>: <span class="pl-s"><span class="pl-pds">"</span>now+3d<span class="pl-pds">"</span></span>
          }
        }
      }
    }
  }</pre></div>
<p dir="auto">This does:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="      &quot;query&quot;: {
        &quot;match_all&quot;: {}
      },
      &quot;filter&quot;: {
        &quot;range&quot;: {
          &quot;screened&quot;: {
            &quot;from&quot;: &quot;now-3d&quot;,
            &quot;to&quot;: &quot;now+3d&quot;
          }
        }
      }"><pre class="notranslate">      <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match_all"</span>: {}
      },
      <span class="pl-ent">"filter"</span>: {
        <span class="pl-ent">"range"</span>: {
          <span class="pl-ent">"screened"</span>: {
            <span class="pl-ent">"from"</span>: <span class="pl-s"><span class="pl-pds">"</span>now-3d<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"to"</span>: <span class="pl-s"><span class="pl-pds">"</span>now+3d<span class="pl-pds">"</span></span>
          }
        }
      }</pre></div>
<p dir="auto">When using <code class="notranslate">"now"</code> in date math in the query string, the value for <code class="notranslate">now</code> is cached:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'  -d '
{
   &quot;mappings&quot; : {
      &quot;test&quot; : {
         &quot;properties&quot; : {
            &quot;date&quot; : {
               &quot;type&quot; : &quot;date&quot;
            }
         }
      }
   }
}
'

curl -XPOST 'http://127.0.0.1:9200/test/test?pretty=1'  -d '
{
   &quot;date&quot; : &quot;2020-01-01&quot;
}
'"><pre class="notranslate"><code class="notranslate">curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'  -d '
{
   "mappings" : {
      "test" : {
         "properties" : {
            "date" : {
               "type" : "date"
            }
         }
      }
   }
}
'

curl -XPOST 'http://127.0.0.1:9200/test/test?pretty=1'  -d '
{
   "date" : "2020-01-01"
}
'
</code></pre></div>
<p dir="auto">Run this query multiple times:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   &quot;query&quot; : {
      &quot;query_string&quot; : {
         &quot;query&quot; : &quot;date:[now TO *]&quot;
      }
   },
   &quot;explain&quot; : 1
}
'"><pre class="notranslate"><code class="notranslate">curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   "query" : {
      "query_string" : {
         "query" : "date:[now TO *]"
      }
   },
   "explain" : 1
}
'
</code></pre></div>
<p dir="auto">You will see that the description line <code class="notranslate">"ConstantScore(date:[1363953493782 TO *])"</code> reuses the same start date</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# {
#    &quot;hits&quot; : {
#       &quot;hits&quot; : [
#          {
#             &quot;_source&quot; : {
#                &quot;date&quot; : &quot;2020-01-01&quot;
#             },
#             &quot;_score&quot; : 1,
#             &quot;_index&quot; : &quot;test&quot;,
#             &quot;_shard&quot; : 4,
#             &quot;_id&quot; : &quot;iOPrtwzdQFGixdfwaAAlcQ&quot;,
#             &quot;_node&quot; : &quot;gx3hk4y7S0Khhx8IQ4uYQQ&quot;,
#             &quot;_type&quot; : &quot;test&quot;,
#             &quot;_explanation&quot; : {
#                &quot;value&quot; : 1,
#                &quot;details&quot; : [
#                   {
#                      &quot;value&quot; : 1,
#                      &quot;description&quot; : &quot;boost&quot;
#                   },
#                   {
#                      &quot;value&quot; : 1,
#                      &quot;description&quot; : &quot;queryNorm&quot;
#                   }
#                ],
#                &quot;description&quot; : &quot;ConstantScore(date:[1363953493782 TO *]), product of:&quot;
#             }
#          }
#       ],
#       &quot;max_score&quot; : 1,
#       &quot;total&quot; : 1
#    },
#    &quot;timed_out&quot; : false,
#    &quot;_shards&quot; : {
#       &quot;failed&quot; : 0,
#       &quot;successful&quot; : 5,
#       &quot;total&quot; : 5
#    },
#    &quot;took&quot; : 5
# }"><pre class="notranslate"><code class="notranslate"># {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "date" : "2020-01-01"
#             },
#             "_score" : 1,
#             "_index" : "test",
#             "_shard" : 4,
#             "_id" : "iOPrtwzdQFGixdfwaAAlcQ",
#             "_node" : "gx3hk4y7S0Khhx8IQ4uYQQ",
#             "_type" : "test",
#             "_explanation" : {
#                "value" : 1,
#                "details" : [
#                   {
#                      "value" : 1,
#                      "description" : "boost"
#                   },
#                   {
#                      "value" : 1,
#                      "description" : "queryNorm"
#                   }
#                ],
#                "description" : "ConstantScore(date:[1363953493782 TO *]), product of:"
#             }
#          }
#       ],
#       "max_score" : 1,
#       "total" : 1
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 5
# }
</code></pre></div>
<p dir="auto">A <code class="notranslate">range</code> query on the other hand, updates the start date on each run:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   &quot;query&quot; : {
      &quot;range&quot; : {
         &quot;date&quot; : {
            &quot;gt&quot; : &quot;now&quot;
         }
      }
   },
   &quot;explain&quot; : 1
}
'"><pre class="notranslate"><code class="notranslate">curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   "query" : {
      "range" : {
         "date" : {
            "gt" : "now"
         }
      }
   },
   "explain" : 1
}
'
</code></pre></div>