diff --git a/ckanext/datesearch/plugin.py b/ckanext/datesearch/plugin.py index a641d1f..a4aefff 100644 --- a/ckanext/datesearch/plugin.py +++ b/ckanext/datesearch/plugin.py @@ -27,16 +27,19 @@ class DateSearchPlugin(plugins.SingletonPlugin): end_date = extras.get('ext_enddate') log.debug("end_date: {0}".format(end_date)) - if not start_date or not end_date: - # The user didn't select a start and end date, so do nothing. + if not start_date and not end_date: + # The user didn't select either a start and/or end date, so do nothing. return search_params + if not start_date: + start_date = '*' + if not end_date: + end_date = '*' - # Add a date-range query with the selected start and end dates into the - # Solr facet queries. + # Add a date-range query with the selected start and/or end dates into the Solr facet queries. fq = search_params['fq'] log.debug("fq: {0}".format(fq)) - fq = '{fq} +metadata_modified:[{start_date} TO {end_date}]'.format( - fq=fq, start_date=start_date, end_date=end_date) + fq = '{fq} +metadata_modified:[{sd} TO {ed}]'.format(fq=fq, sd=start_date, ed=end_date) + log.debug("fq: {0}".format(fq)) search_params['fq'] = fq log.debug("search_params: {0}".format(search_params))