Combining start_range and end_range with other queries

n1ql

#1

We are working with geographic feature data that is organised by an attribute called “layers” (within the same data bucket). We wish to make geospatial queries over these features, and partition the data into sets of layers. As an example of such features:

{
    "type":"Feature",
    "layer": "Buildings",
    "properties" {
        // ...
    }
    "geometry": {
        // ...
    }
}

and

{
    "type":"Feature",
    "layer": "Parks",
    "properties" {
        // ...
    }
    "geometry": {
        // ...
    }
}

We would like to be able to find all features that exist within a geographic bounding box AND are in any one of a set of layers. In theory, equivalent to a query such as:

&start_range=[0,-90]&end_range=[180,90]&keys=["Buildings","Parks"]

However this does not seem to be possible. Furthermore, it’s not feasible for us to create one view per layer type, as there may be may dozens of these defined in the data bucket. The query, however, will likely only test against a small handful. Therefore, the only solution I have found so far is to encode the layer name numerically, include a 3rd dimension to the start_range and end_range, and make multiple queries.

Is there a better approach? Is there a way to partition data buckets to make such queries simpler? Alternatively, is there an efficient N1QL approach?

Thanks for your help.