0

Below is the response from my spatial view query in Couchbase by providing bounding box parameters:

{
    "rows":[
        {
            "geometry":{
                "type":"Point",
                "coordinates":[
                    -71.10364,
                    42.381411
                ]
            },
            "value":{
                "location":{
                    "type":"Point",
                    "coordinates":[
                        -71.10364,
                        42.381411
                    ]
                },
                "name":"test",
                "visibility":"public",

            },
            "id":"test",
            "key":[
                [
                    -71.10364,
                    -71.10364
                ],
                [
                    42.381411,
                    42.381411
                ]
            ]
        }
    ]
}

and here is my spatial view query:-

function (doc, meta) {
    if (doc.type == "folder" && doc.location && doc.location.type) {

          if(doc.location.type=='Point'){ 
             var visibility      = doc.enabled === true ? 'public' : 'private';
              emit(doc.location, {
                name:doc.name,
                folder_id:doc.folder_id,
                location: doc.location,
                visibility:visibility
              });
          }
    }
}

but the JSON response contains unwanted data, so i am wondering how can i remove geometry and key parameter from json response.

Also query returns first 10 records, is there any way so i can set limit and skip parameters so query return all data instead first 10.

DaveR
  • 9,540
  • 3
  • 39
  • 58
rash
  • 91
  • 7
  • I dont understand the first half of your question: according to the view above you're not emitting geometry or key - but rather a subset of the document's fields. Regardless, you might want to look at python's dictionary's pop() function if you want to remove items from dicts. – FuzzyAmi Aug 06 '15 at 16:27
  • i dont want geometry and key data in response – rash111 Aug 07 '15 at 07:17

2 Answers2

0

To answer the 2nd half of your question (please post two separate questions next time): yes, views support pagination. You can set the number of results. you can ask for x results per page and for different pages. See this: http://blog.couchbase.com/pagination-couchbase

And also: dev-views only work on part of your bucket. Publish them to get results that corresponds to the entire data.

FuzzyAmi
  • 7,543
  • 6
  • 45
  • 79
0

You can't remove the geometry and key - both are part of the result. If you don't want to use them when simply don't do anything with them.

DaveR
  • 9,540
  • 3
  • 39
  • 58