Writing spatial views with Python
Fri, 01/04/2013 - 17:12
Hi
I can load spatial data from ArcGIS with Python and create views using the console, but I can't find sample code on writing design documents to Couchbase with Python. Anyone have some code they can share? Thanks.
Mon, 01/07/2013 - 13:49
Hi
Thanks, I can write a doc into a bucket with that approach, but attempting to display the doc returns:
Error: notfound (Document does not exist)
Also, no view is created, just the doc entry, which appears broken.
I'll try via REST.
Regards
Mon, 01/07/2013 - 14:30
Breaking news: I must have a syntax issue, I can create a simpler view with the approach, I'll chase down the issue.
Thanks again
Hello,
I am not a Python expert so I will just point you to some sample code of give you ideas.
It looks like this library supports create/edit design documents:
- https://github.com/couchbase/couchbase-python-client
using something like:
design_doc = {"views": {"all_by_types": {"map": '''function (doc, meta) { emit([meta.type, doc.type, meta.id], doc.value); // row output: ['json', 'item', 'key4'], 'json test' }''' }, }, } # save a design document newbucket['_design/testing'] = design_docAlso keep in mind that the creation of view is something that could be done using REST API calls, that you can do in your script.
You can find information about REST API here: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-desig...
Regards
Tug
@tgrall