[ckan-dev] return specified results through datastore_search API
Dominik Moritz
dominik.moritz at okfn.org
Tue May 14 09:40:44 UTC 2013
Hi,
On 14 May 2013, at 03:53, 天龙出云 <dragoniszhang at gmail.com> wrote:
> hello everyone,
>
> I want to use datastore_search API to find specified results with curl
> command like the following:
> curl
> http://127.0.0.1:5000/api/3/action/datastore_search?resource_id=adae6ab9-731d-462a-82c9-fd1e8c9ea3f6&fields='c,n
> '
> the value of fields 'c,n' are the column name of the table in datastore
> database.
It does work for me. See http://demo.ckan.org/api/action/datastore_search?resource_id=f6331f99-51f6-44d9-95b9-b20f3b74f360&fields=lat,lon
If that does not work, you should try to use POST instead of GET requests.
> The problem is that the returned results still contain all the information
> instead of the specified results I wish. Is there any problem with my curl
> command? I did not find a detailed tutorial to use datastore_search API
> with multiple parameters.
We have the docs at http://docs.ckan.org/en/latest/api.html and http://docs.ckan.org/en/latest/datastore-api.html. I'm afraid we don't have a tutorial but I hope you find help in the docs.
>
> Another question is that if I want to give aliases to a resource on the web
> page, where can I input the aliases to send to the datastore_create API? I
> did not see anywhere to input the aliases attribute when I create a
> resource on web page.
You can't create an alias through the Interface. It's really easy to do it through the API, though. You need to send a POST request with a json object like this:
to datastore_create
{
"resource_id": "adae6ab9-731d-462a-82c9",
"aliases": "my_alias",
"fields": [{"id": "book", "type": "text"},
{"id": "author", "type": "text"}]
...
}
Hope that helps,
Dominik
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
Dominik Moritz
CKAN developer | skype: d.moritz | @doobly_doo
The Open Knowledge Foundation
Empowering through Open Knowledge
http://okfn.org/ | @okfn | http://ckan.org | @CKANproject
More information about the ckan-dev
mailing list