: We're still not seeing the proper result.  I've included a gist of the 
: query and its debug result.  This was run on a clean index running 4.4.0 
: with just one document.  That document has a date of 11/15/2013 yet the 
: date in the included TZ it is the 14th but I still get that document 
: returned.  Hoping someone can help.
: 
: https://gist.github.com/anonymous/7478773

1) please don't use gist/pastie URLs in email -- they can be 
changed/deleted after you send your email, making it impossible for people 
reading email archives to udnerstand your question or learn aything from 
the examples later.  Just include the output in the body of your email

2) you haven't included enough information (either in your email or in 
the gist) to make sense of the behavior you are seeing:

a) what *exact* value is in the index for this document?
b) what *exact* time did you run the query?

you use expressions like "date of 11/15/2013" and "the 14th" but those are 
vague concepts that could mean specific moments in time in ranges of up 
to 48 hours (depending on what timezone you mean when you refer to them 
as a string in terms of "days")

Here's some simple, concrete, examples using the Solr example configs to 
help show you how the TZ option affects date math.  These examples don't 
require any documents to be indexed...

w/o TZ, so all math is relative to UTC...

$ date --utc && curl -s 
'http://localhost:8983/solr/collection1/query?omitHeader=true&debug=query&q=*:*&fq=now_dt:NOW&fq=today_dt:NOW/DAY&fq=tomorrow_dt:NOW/DAY%2B1DAY&&fq=lastmonth_dt:NOW-1MONTH/DAY&fq=specific_rounded_dt:"2013-07-04T12:34:56Z/DAY";'
 | grep 2013 | grep -v DAY
Mon Nov 18 18:58:57 UTC 2013
    "parsed_filter_queries":["now_dt:2013-11-18T18:58:57.813Z",
      "today_dt:2013-11-18T00:00:00Z",
      "tomorrow_dt:2013-11-19T00:00:00Z",
      "lastmonth_dt:2013-10-18T00:00:00Z",
      "specific_rounded_dt:2013-07-04T00:00:00Z"]}}


w/TZ = America/Los_Angeles...

$ date --utc && curl -s 
'http://localhost:8983/solr/collection1/query?omitHeader=true&debug=query&q=*:*&fq=now_dt:NOW&fq=today_dt:NOW/DAY&fq=tomorrow_dt:NOW/DAY%2B1DAY&&fq=lastmonth_dt:NOW-1MONTH/DAY&fq=specific_rounded_dt:"2013-07-04T12:34:56Z/DAY"&TZ=America/Los_Angeles'
 | grep 2013 | grep -v DAY
Mon Nov 18 18:58:27 UTC 2013
    "parsed_filter_queries":["now_dt:2013-11-18T18:58:27.477Z",
      "today_dt:2013-11-18T08:00:00Z",
      "tomorrow_dt:2013-11-19T08:00:00Z",
      "lastmonth_dt:2013-10-18T07:00:00Z",
      "specific_rounded_dt:2013-07-04T07:00:00Z"]}}


Below is my best effort to reproduce what you seemed to be describing that 
you were trying to do, which works as expected.  Note that the document 
i've indexed has a field value of "2013-11-19T01:00:00Z".  

In the first query, at "Mon Nov 18 19:12:07 UTC 2013" we ask Solr to 
compute "NOW/DAY+1DAY" using UTC to define the start of the current day: 
as a result that document does not match our query.  In the second query, 
executed at "Mon Nov 18 19:12:29 UTC 2013", we tell solr to use 
America/Los_Angeles when rounding to the nearest "day": as a result, the 
document *does* match our query, because 2013-11-19T01:00:00Z is before 
the start of the "tomorrow" in terms of the start of day conventions 
for America/Los_Angeles (ie: ...T08:00:00 UTC).

(One thing to note about these examples, is that unlike the simple 
term queries from my above examples, when outputing a range 
query over a date, the debug output displays the ranges in terms of "ms 
since epoch) so i've also included some basic re-formatting after each 
example query)

$ curl -H 'Content-Type: application/xml' -d '<add><doc><field 
name="id">HOSS</field><field 
name="my_dt">2013-11-19T01:00:00Z</field></doc></add>' 
'http://localhost:8983/solr/collection1/update?commit=true'
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int 
name="QTime">562</int></lst>
</response>

$ date --utc && curl 
'http://localhost:8983/solr/collection1/query?q=my_dt:\[*+TO+NOW/DAY%2B1DAY\]&debug=query'
Mon Nov 18 19:12:07 UTC 2013
{
  "responseHeader":{
    "status":0,
    "QTime":6,
    "params":{
      "q":"my_dt:[* TO NOW/DAY+1DAY]",
      "debug":"query"}},
  "response":{"numFound":0,"start":0,"docs":[]
  },
  "debug":{
    "rawquerystring":"my_dt:[* TO NOW/DAY+1DAY]",
    "querystring":"my_dt:[* TO NOW/DAY+1DAY]",
    "parsedquery":"my_dt:[* TO 1384819200000]",
    "parsedquery_toString":"my_dt:[* TO 1384819200000]",
    "QParser":"LuceneQParser"}}
$ date --utc --date="@1384819200"
Tue Nov 19 00:00:00 UTC 2013

$ date --utc && curl 
'http://localhost:8983/solr/collection1/query?q=my_dt:\[*+TO+NOW/DAY%2B1DAY\]&TZ=America/Los_Angeles&debug=query'
Mon Nov 18 19:12:29 UTC 2013
{
  "responseHeader":{
    "status":0,
    "QTime":2,
    "params":{
      "q":"my_dt:[* TO NOW/DAY+1DAY]",
      "debug":"query",
      "TZ":"America/Los_Angeles"}},
  "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"HOSS",
        "my_dt":"2013-11-19T01:00:00Z",
        "_version_":1452070046839865344}]
  },
  "debug":{
    "rawquerystring":"my_dt:[* TO NOW/DAY+1DAY]",
    "querystring":"my_dt:[* TO NOW/DAY+1DAY]",
    "parsedquery":"my_dt:[* TO 1384848000000]",
    "parsedquery_toString":"my_dt:[* TO 1384848000000]",
    "QParser":"LuceneQParser"}}
$ date --utc --date="@1384848000"
Tue Nov 19 08:00:00 UTC 2013


-Hoss

Reply via email to