Updated the temporal query

This commit is contained in:
Francesco Mangiacrapa 2019-10-24 12:05:53 +02:00
parent 6925b943b4
commit 57d2d7c778
2 changed files with 17 additions and 8 deletions

View File

@ -33,13 +33,19 @@ class DateSearchPlugin(plugins.SingletonPlugin):
end_date = '*'
# Add a date-range query with the selected start and/or end dates into the Solr facet queries.
fq = search_params.get('fq', '')
#fq = search_params.get('fq', '')
#fq = '{fq} +extras_PublicationTimestamp:[{sd} TO {ed}]'.format(fq=fq, sd=start_date, ed=end_date)
#fq = '{fq} +metadata_modified:[{start_date} TO {end_date}]'.format(fq=fq, start_date=start_date, end_date=end_date)
#search_params['fq'] = fq
# Added by Francesco see: https://github.com/geosolutions-it/ckanext-datesearch
fq = '{fq} +metadata_modified:[{start_date} TO {end_date}]'.format(fq=fq, start_date=start_date, end_date=end_date)
log.info('fq is: '+str(fq))
search_params['fq'] = fq
# Updated by Francesco see: https://github.com/geosolutions-it/ckanext-datesearch
# Add a date-range query with the selected start and/or end dates into the Solr queries.
#MAYBE CAN BE OPTIMIZED
fq = search_params.get('fq', '')
fq = '({fq} -time_date:[* TO *])'.format(fq=fq) + ' OR ({fq} +time_date:[{start_date} TO {end_date}])'.format(fq=fq, start_date=start_date, end_date=end_date)
#NB. I'M CHANGING THE QUERY NOT THE FACET QUERY
search_params['q'] = fq
log.debug('search_params["q"] is: '+str(search_params['q']))
return search_params

View File

@ -17,14 +17,17 @@
<table id="daterange-table">
<tr>
<td><span class="add-on" style="border:none;background-color:#ffffff;">From&nbsp;&nbsp;</span></td>
<td><input type="text" class="input-mini" readonly="" name="start" id="start" data-module="daterangepicker-module" /></td>
<td><input type="text" class="input-mini" readonly="" name="start" id="start" data-module="daterangepicker-module" placeholder="Start time" /></td>
</tr>
<tr>
<td><span class="add-on" style="border:none;background-color:#ffffff;">To&nbsp;&nbsp;</span></td>
<td><input type="text" class="input-mini" readonly="" name="end" id="end" data-module="daterangepicker-module" /></td>
<td><input type="text" class="input-mini" readonly="" name="end" id="end" data-module="daterangepicker-module" placeholder="End time" /></td>
</tr>
</table>
</div>
<!--<p style="margin-left: 15px; font-size: 12px;">
<a href="?q=time_date:*" title="Get all temporal {{ _('dataset') }}">See All</a>
</p>-->
</section>
{{ super() }}