Start a new topic

Trying "query.near" in the Console API, always returns all the rows from my collection

Hello! 


I am learning about Kinvey now and I would like to make a filter to get all records containing the movie theaters that are within a five mile radius of where I am located, for example.


I tried the following command line in the Console API: 


/appdata/................/my-theaters?query.near("_geoloc", "-49.933333,-22.216667", 0);


But always returns all records ignoring the filter.


Could you tell me, please, if the error is in the filter or in my data structure below?

 

================

HTTP/1.1 200 SUCCESS

Fri Aug 07 2015 20:53:26 GMT-0300 (Hora oficial do Brasil)

[

  {

    "_id": "55c54????????5e84901f9b5",

    "id_admin": 2,

    "theater_type": 2,

    "theater_name": "Briar Street Theatre",

    "event": "The Sound of Music",

    "theater_address": "Av Pedro de toledo, 22",

    "country": "Brasil",

    "city": "Bauru",

    "_geoloc": [

      -49.933333,

      -22.216667

    ],

    "_acl": {

      "creator": "kid_????????Ex"

    },

    "_kmd": {

      "lmt": "2015-08-07T23:42:06.835Z",

      "ect": "2015-08-07T23:34:29.431Z"

    }

  },

  {

    "_id": "55c54????????0193f00f5f9",

    "id_admin": "2",

    "theater_type": 2,

    "theater_name": "New Amsterdam Theatre",

    "event": "Blue Man Group",

    "theater_address": "Av Pedro de toledo, 22",

    "country": "USA", 

    "city": "New York, NY",

    "_geoloc": [

      -49.0750992,

      -22.307512

    ],

    "_acl": {

      "creator": "kid_????????Ex"

    },

    "_kmd": {

      "lmt": "2015-08-07T23:45:39.453Z",

      "ect": "2015-08-07T23:43:24.856Z"

    }

  },

  {

    "_id": "55c542e5b????????907757a",

    "id_admin": "2",

    "theater_type": 2,

    "theater_name": "Astor Place Theatre",

    "event": "Hershey Felder as Irving Berlin",

    "theater_address": "Av Pedro de toledo, 22",

    "country": "USA", 

    "city": "New York, NY",

    "_geoloc": [

      -49.933333,

      -22.216667

    ],

    "_acl": {

      "creator": "kid_????????Ex"

    },

    "_kmd": {

      "lmt": "2015-08-07T23:45:10.756Z",

      "ect": "2015-08-07T23:44:37.653Z"

    }

  }

]



I would appreciate any help!


Marco


Hello Macro,


I don't believe that near is a function that we support, we do however support nearSphere (Which is outlined here:  http://devcenter.kinvey.com/rest/guides/location  ) with a handful of examples.  In your case your query would most likely look something more like:


/appdata/................/my-theaters?query={"_geoloc": {"$nearSphere": [-49.933333,-22.216667]}}


You can also specify a max distance for the sphere to contain, which is also outlined in the rest API guide above.


Also, closed the second topic of this as a duplicate of this request.


Please let me know if you have any other questions.


Thanks,


1 person likes this

Hello Damien!

Thank you very much!

The query is working fine now, including max distance.

Sorry for duplicate topic, I thought that the "comment" had not worked.

Best regards,

Marco

Login or Signup to post a comment