0

could i write like this?

function (doc,meta) {

emit([[doc.range1, doc.range2],[doc.range3, doc.range4]], doc.comment); 

}

i just want to find data use two range.I found a example that is

emit([10.9, 48.4, [1000, 2000]], null);

the range [1000,2000] does it can filter data?

mikewied
  • 5,273
  • 1
  • 20
  • 32
胡胡博
  • 1
  • 1

2 Answers2

0

The following link will help: http://developer.couchbase.com/documentation/server/4.0/sdks/dotnet-2.2/geo-spatial-views.html

And remember, spatial feature is experimental before version 4.0. For use with python, in my case, it provides SpatialQuery object.
(from couchbase.views.params import SpatialQuery)

Intae Kim
  • 309
  • 1
  • 5
0

supposing you have a json document shaped this way

{
  "resourceId": "3c0d9906-4e88-4b12-b96b-9d7377a503a9", 
  "_type": "com.sample.model.Position",
  "updated": 1510790620782,
  "point": {
  "coordinates": [15.704621,40.2755],
 "type": "Point"
 }
}

you can write a spatial view this way

function (doc) {
if (typeof doc.point !== 'undefined' && doc._type == "com.sample.model.Position") {
    var date = Date.parse(doc.updated) / 1000;
    emit(doc.point, doc.resourceId);
    }
}

you can use the browser to design your docuement: go to http://localhost:8091 enter index -> view menu from there you can test the view with real document from your data this create the index; to query the index you can use the geo funcions even with rest as described by

official documentation

hope it helps

Loki
  • 659
  • 1
  • 8
  • 18