Hello,
After so many hours, I finally found whats going on. Probably a bug on your end ( or a fix needed at my end). The issue I run into is that I get no results back after I delete a collection and readd it. Lets assume that You have an empty db withno collections. Here is the code I use to add the location ( I am not using the Geotag code as I need to update the same location over and over again as per on of the asked questions by fellow users)
dbName="mydb";
collectionName = "coll";
JSONObject jsonDoc = new JSONObject();
double lat = loc.getLatitude(); //loc is my location obtained from gps
double lng = loc.getLongitude();
String key = "UserId";
String value = "Random111";
try {
jsonDoc.put(JSONUserId, Services.userName);
jsonDoc.put(JSONDob, utcDateFormat);
jsonDoc.put(JSONLoc, "["+lat+"," + lng+"]");
} catch (JSONException e) {
e.printStackTrace();
return ;
}
storageService.saveOrUpdateDocumentByKeyValue(dbName, collectionName, key, value, jsonDoc, null);
Here is the code for getting the locations back
double lat = loc.getLatitude(); //another loc that is very close (within meters)
double lng = loc.getLongitude();
BigDecimal distanceInKM = new BigDecimal(10); //10km
GeoTag gp = new GeoTag();
gp.setLat(new BigDecimal(lat));
gp.setLng(new BigDecimal(lng));
GeoQuery query = QueryBuilder.buildGeoQuery(gp, GeoOperator.NEAR, distanceInKM);
// find documents by geo query.
storageService.findDocumentsByLocation(dbName, collectionName, query, new App42CallBack() {
......
});
If you do the above on a DB with no collection then the first call creates collecion COLL and add the entry above. I check on the dash board and the location column has the right location. However, when I query , I get the error msg "No collections exist"
Now, delete the collection from the dashboard. Create it again by adding the entry using the dashboard manually (using the same Geo coordinates) and run the code above then the locations are fetched. Even if the code above creates new locations, they are all fetched correctly. It seems that somehow, The first entry used to create the location will have to be either added manually from the dashboard OR use the code that does storageService.setGeoTag for the first location only.
Are you aware of this issue? Any pointers?
Thank you so much