[ckan-dev] temporal search plugin

Adrià Mercader adria.mercader at okfn.org
Wed Oct 22 09:37:15 UTC 2014


Hi Renato,

As described on the plugins README, CKAN supports date searches out of
the box, eg

http://demo.ckan.org/dataset?q=metadata_modified%3A[2013-08-01T00%3A00%3A00Z+TO+2014-08-31T00%3A00%3A00Z]
http://demo.ckan.org/api/action/package_search?q=metadata_modified%3A[2013-08-01T00%3A00%3A00Z+TO+2014-08-31T00%3A00%3A00Z]

The field you choose to search on will be up to you.
"metadata_modified" isn't stored anywhere on the database, is
generated based on the revisions on the dataset. "temporal" is not a
field in the core schema, so I guess it was harvested or entered
manually via the ui. One thing to notice is that if you want to
perform a date search you either 1) need to use a field ending with
"_date", as this will be indexed in Solr as date or 2) Use a custom
Solr schema where you index your custom field as a date.

 Of course if you need to search a date range you will need a field
for the start and one for the end date. You can have a look at this
instance for an example of how this can be done. Notice the date
slider on the left column.

http://data.satapps.org/dataset

The fields on this case are called "begin-collection_date" and
"end-collection_date", but this can be replaced by any "_date" field
that you need. Probably the most relevant code is here:

https://github.com/okfn/ckanext-tsbsatellites/blob/master/ckanext/tsbsatellites/plugin.py#L73


Hope these pointers help

Adrià

On 21 October 2014 20:27, Renato Guevara <guevara.renato at gmail.com> wrote:
> I researched online for a plugin that can give me temporal search
> capabilities.  It seems that there were two plugins out there, namely:
>
> https://github.com/seanh/ckanext-datesearch
>
> and
>
> https://github.com/B2FIND/ckanext-datesearch
>
> I ended up using the second one because it actually ran a search (as the
> first one didn't do anything but maybe I wasn't configuring it correctly),
> however I modified it so that I could search based on Zulu dates.  I also
> made the change in the plugin.py so that it'd search on the "temporal" field
> instead of the "metadata_modified" field.  This is where I'm tripping up a
> bit.  According to DCAT, the temporal field is formatted as follows:
> start_date/end_date.  However, when I run a temporal search it only seems to
> be search based on my start_date.  I tried to go into the psql database to
> see where temporal would be stored, but I couldn't find it.  I suspect it
> should be located in the package_extra table but I couldn't find this
> information.  I have two datasets in my ckan instance.  One of which was
> imported using a harvester, and another one was entered manually through the
> web UI.  Both have a field called "temporal".  Do I have to do anything
> special to have this field in the database?
>
> Any help would be much appreciated!
>
> Thanks!
>
> Renato Guevara
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>



More information about the ckan-dev mailing list