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:

{"error":"error","reason":"{index_builder_exit,139,<<>>}"}

from queries such as:

http://localhost:8092/feature/_design/dev_foo/_spatial/bar?bbox=-180%2C-90%2C180%2C90&stale=false&connection_timeout=60000&full_set=true

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@127.0.0.1:<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 https://github.com/couchbase/geocouch/wiki/Spatial-Views-API (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.