Does Kinvey's RESTAPI support geolocation based queries inside documents? The documentation https://devcenter.kinvey.com/rest/guides/location says I have to create a _geoloc field on record level in order to get a 2D index created. Does that mean it wont work storing geolocations (coordinates) stored in documents?
Can you please elaborate your usecase?
As far I know, "_geoloc" information needs to be present in the collection and then you have to query that collection using location coordinates using REST API console or SDK methods available.
Okay, I can try that out once. I went through Kinvey's Location documentation and MongoDB's Location documentation as well. MongoDB offers some more Location based options that I thought I would need it but I can handle everything with the possibilities what Kinvey offers here. So it's no more a big issue for my project. It might be that Location queries might work in documents but as far as I understood MongoDB's documentation: You NEED a 2DIndex or a 2DSphere index on it to process such queries. The Kinvey documentation says that only a 2DIndex will be automatically created on toplevel fields called '_geoloc', thats why I am unsure if Location queries might work inside a document.
My usecase looks like this: I'm working on a GPS located based game while a single game can have 1 or more locations/coordinates (1-to-many relation). On publishing a game some locations of that game must have a minimum distance to some other locations of all already published games. It would have been neat to store a document containing all locations of/with a game for the mentioned distance checks.
The current possibilities wants me to create a separate collection (lets call it Locations) in which I store all relevant GPS locations of published games to check (distance) against later published games. Thats not a big issue but on re-publishing a game (thats possible) I have to make sure the Location collection is uptodate:
1. Delete all existing stored GPS coordinates in collection Locations of the re-published game and add all again from the re-published game (that might have changed or partially removed).
2. Insert the current GPS locations of the re-published game.
This works for me, just causes more traffic and processing stuff.
In the optimal case (as described: all locations stored in a document together with the game itself and not in a separate collection) I only would have to update the game record on re-publishing to be up-to-date (no deletes, no re-inserts) => but unsure if distance queries/checks would work here (without 2D-Indexing).
So I can handle that all with the Kinveys currently provided solution, no further investigations required from your side. If I can find time I will have a closer look into the optimal solution and try out location queries in documents.