ckan/ckan — pull request #1701 by amercader (2014-05-16 17:13:02+00:00)
Title: Current date indexed on empty "*_date" fields

When indexing a dataset, we are indexing any field (generally an extra) ending in `_date` as a `DateType` field in Solr.

To make sure we are indexing a proper date and Solr does not return an exception, we use [dateutil.parse](https://labix.org/python-dateutil#head-c0e81a473b647dfa787dc11e8c69557ec2c3ecd2) to try and parse different date formats. If the string is not a date at all we just ignore the field:

https://github.com/ckan/ckan/blob/master/ckan/lib/search/index.py#L222

There is a problem when the field is actually empty though. `dateutil.parse` will always return a date by default (the current one if another one is not provided using the `default` parameter). This is probably not the expected behaviour, where I wouldn't want the field to be indexed at all.

We probably need to provide a very unlikely default (0001-01-01), check if the parsed date is the same and remove the field if so.