[ckan-dev] ckan api: remove ES stuff?

Rufus Pollock rufus.pollock at okfn.org
Thu Apr 26 22:38:00 UTC 2012


On 26 April 2012 16:52, James Casbon <casbon at gmail.com> wrote:
> Hi All,
>
> First of all thanks for fixing the CORS requests issues that were preventing
> me using the data api in a JS app.  But... is it possible to remove (what
> looks like) the search meta information from the results.

Yes fixed a few weeks ago now :-)

> ie.
>
>>>> url =
>>>> 'http://thedatahub.org/api/data/b9aae52b-b082-4159-b46f-7bb9c158d013/_search?size=5'
>>>> import json, urllib
>>>> pprint(json.loads(urllib.urlopen(url).read()))
> {u'_shards': {u'failed': 0, u'successful': 5, u'total': 5},
>  u'hits': {u'hits': [{u'_id': u'MdbtPhg8Q3WVM6gGw2tMVQ',
>                       u'_index': u'ckan-www.ckan.net',
>                       u'_score': 1.0,
>                       u'_source': {u'__id__': u'51',
>                                    u'date': u'1954-03',
>                                    u'price': u'34.92'},
>                       u'_type': u'b9aae52b-b082-4159-b46f-7bb9c158d013'},
> ...

simple answer is: no :-)

We intentionally return exactly what ElasticSearch gives us so that
you can a) use libraries designed for ES with CKAN Data API b) you can
switch seamlessly between CKAN data API and ES (if you want to work
locally).

I know it is slightly annoying but it's a tiny amount of data and you
can just do data.hits to get the stuff immediately.

Also why not just use recline if you are using JS -- the ES backend
will automatically convert the data to nice backbone documents for you
...?

Rufus

> Would look like:
>>>> pprint(json.loads(urllib.urlopen(url).read()))
>  [ {u'__id__': u'51',
>     u'date': u'1954-03',
>     u'price': u'34.92'},
> ...
>
>
> Thanks,
> James
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>



-- 
Co-Founder, Open Knowledge Foundation
Promoting Open Knowledge in a Digital Age
http://www.okfn.org/ - http://blog.okfn.org/




More information about the ckan-dev mailing list