views:

158

answers:

1

Date ranges including BC dates is this possible?

I would like to return facets for all years between 11000 BCE (BC) and 9000 BCE (BC) using SOLR.

A sample query might be with date ranges converted to ISO 8601:

q=*:*&facet.date=myfield_earliestDate&facet.date.end=-92009-01-01T00:00:00&facet.date.gap=%2B1000YEAR&facet.date.other=all&facet=on&f.myfield_earliestDate.facet.date.start=-112009-01-01T00:00:00

However the returned results seem to be suggest that dates are in positive range, ie CE, not BCE...

see sample returned results

<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">6</int>
<lst name="params">
<str name="f.vra.work.creation.earliestDate.facet.date.start">-112009-01-01T00:00:00Z</str>
<str name="facet">on</str>
<str name="q">*:*</str>
<str name="facet.date">vra.work.creation.earliestDate</str>
<str name="facet.date.gap">+1000YEAR</str>
<str name="facet.date.other">all</str>
<str name="facet.date.end">-92009-01-01T00:00:00Z</str>
</lst>
</lst>
<result name="response" numFound="9556" start="0">ommitted</result>
<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields"/>
<lst name="facet_dates">
<lst name="vra.work.creation.earliestDate">
<int name="112010-01-01T00:00:00Z">0</int>
<int name="111010-01-01T00:00:00Z">0</int>
<int name="110010-01-01T00:00:00Z">0</int>
<int name="109010-01-01T00:00:00Z">0</int>
<int name="108010-01-01T00:00:00Z">0</int>
<int name="107010-01-01T00:00:00Z">0</int>
<int name="106010-01-01T00:00:00Z">0</int>
<int name="105010-01-01T00:00:00Z">0</int>
<int name="104010-01-01T00:00:00Z">0</int>
<int name="103010-01-01T00:00:00Z">0</int>
<int name="102010-01-01T00:00:00Z">0</int>
<int name="101010-01-01T00:00:00Z">0</int>
<int name="100010-01-01T00:00:00Z">5781</int>
<int name="99010-01-01T00:00:00Z">0</int>
<int name="98010-01-01T00:00:00Z">0</int>
<int name="97010-01-01T00:00:00Z">0</int>
<int name="96010-01-01T00:00:00Z">0</int>
<int name="95010-01-01T00:00:00Z">0</int>
<int name="94010-01-01T00:00:00Z">0</int>
<int name="93010-01-01T00:00:00Z">0</int>
<str name="gap">+1000YEAR</str>
<date name="end">92010-01-01T00:00:00Z</date>
<int name="before">224</int>
<int name="after">0</int>
<int name="between">5690</int>
</lst>
</lst>
</lst>
</response>

Any ideas why this is the case, can solr handle negative dates such as -112009-01-01T00:00:00Z?

A: 

I don't think this is fully supported. At least I don't see any explicit references to BC dates in the source code or the tests.

I even tried defining BC years using date math, e.g:

facet.date.start: NOW-11000YEARS
facet.date.end: NOW
facet.date.gap: +1000YEAR

and got some weird results:

<int name="8991-06-07T20:30:45-.666Z">0</int>
<int name="7991-06-07T20:30:45-.666Z">0</int>
<int name="6991-06-07T20:30:45-.666Z">0</int>
<int name="5991-06-07T20:30:45-.666Z">0</int>
<int name="4991-06-07T20:30:45-.666Z">0</int>
<int name="3991-06-07T20:30:45-.666Z">0</int>
<int name="2991-06-07T20:30:45-.666Z">0</int>
<int name="1991-06-07T20:30:45-.666Z">0</int>
<int name="0991-06-07T20:30:45-.666Z">0</int>
<int name="0010-06-07T20:30:45-.666Z">0</int>
<int name="1010-06-07T20:30:45-.666Z">1435</int>

Note the - after the seconds. Looks like a bug to me...

Mauricio Scheffer
I can confirm the same issue with `-` for queries composed with date math, as well as the issue with iso 8601 (negative) dates such as "-112009-01-01T00:00:00Z". I will post this on Apache Jira shortly. Thanks for confirming this. On a side note to select a facet returned from the range query on dates, a facet query such as fq=dateFieldName:2009-01-01T00:00:00Z is still appropriate?
Nigel_V_Thomas