Spatial views and geometry size limits



Whenever I add a document to my data bucket, with a very large geometry, e.g.:

{"id": "1234",
 "geometry": {"type":"Polygon","coordinates":[[[145,-38],[145.1,-38.1], ...10,000 more ... ]]}}

I get the error:


from queries such as:


where ‘bar’ is the most basic spatial view:

function (doc) {
    if (doc.geometry) {
        emit(doc.geometry, null);

I’ve verified that it’s caused by the geometry being too large. I’ve generated Polygons (squares) with an increasing number of points, and beyond a certain amount, the queries fail.

Is there a documented limit on how big the geometry can be for spatial queries? Is there a workaround, or at least the ability to ignore geometries that are too large, instead of failing completely?

I’m using Couchbase server 3.0.2

Thanks for your help,


Thanks for bringing up the issue. There are no known limits. I’ll have a look and filed a bug MB-14401 for it in case you want to track it.


Quick update. I can reproduce it. There should be an error in the mapreduce.log. Something like:

[mapreduce_errors:error,2015-04-09T23:31:17.597,couchdb_n_0@<0.1684.0>:couch_set_view_updater:-do_maps/3-fun-0-:783]Bucket `default`, main group `_design/dev_foo`, error mapping document `doc-428` for view `baz`: too long key emitted: 4099 bytes

It of course isn’t right as it should evaluate the size of the key after the geometry was processed. Let’s hope it’s easy to do :slight_smile:


It’s fixed for the upcoming release.

A workaround for the current version would be that you calculate the bounding box before you emit it and use it as a key. Though you then won’t have the original geometry in the result expect if you emit it as a key.

See more about the current API at (until the docs for the upcoming version are published).


Thank you very much for the very fast turnaround.

Until that release, we will do as you suggest: calculate the bounding box of each over-sized geometry first.