GeoSearch Returns Nothing

ios
swift3
geosearch

#1

So I am working on migrating my geoSearch functionality from GeoFire to Algolia because there are more options as far as filtering, and many other things that could make life a heck of a lot easier.

I am currently using it to search for events nearest a users location. Just as the docs say (https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/) I have added this attribute

“_geoloc”: {
“lat”: 37.7909427,
“lng”: -122.4084994
}

To make geosearching possible. Following that I use SwiftLocation to grab the users current latitude and longitude for my geo query/search. The docs say do something like this (https://www.algolia.com/doc/api-reference/api-parameters/aroundLatLng/)

let query = Query(query: "query")
query.aroundLatLng = LatLng(lat: 40.71, lng: -74.01)

index.search(query, completionHandler: { (res, error) in
  print(res)
})

Which I accomplish with this block of code

static func fetchEventsFromAlgolia(completion: @escaping (String) -> Void) {
    
    let client = Client(appID: Algolia.appID, apiKey: Algolia.apiKey)
    let index = client.index(withName:indice.events)
    let query = Query(query: "query")

    LocationService.getUserLocation { (currentLocation) in
        
        guard let latitude = currentLocation?.coordinate.latitude else {
            completion("error finding latitude")
            return
        }
        
        guard let longitude = currentLocation?.coordinate.longitude else {
            completion("error finding longitude")
            return
        }
        
        query.aroundLatLng = LatLng(lat: latitude, lng:longitude )
        query.aroundRadius = .all
        index.search(query, completionHandler: { (res, err) in
            if err == nil {
                guard let res = res else {
                    completion("error with res unwrapping")
                    return
                }
                
                
                let data = res["hits"]! as! [NSDictionary]
                print("Result: \(data.count)")
                print(res.description)
                completion("success events should have been printed")
            }else {
                completion(err as! String)
            }
        })
        
        
    }
    
}

However when I print the results to the terminal I get nothing. It seems as though it successfully does the query but not results come back.

Here is what one of the event entries looks like in Algolia for my specific case

{
  "attend:count": 6,
  "event:category": "concert",
  "event:city": "San Francisco",
  "event:date": {
    "end:date": "05/11/2019",
    "end:time": "11:35 PM",
    "start:date": "04/19/2019",
    "start:time": "10:55 PM"
  },
  "event:datetime": {
    "end": 1557632100,
    "start": 1555728900
  },
  "event:description": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
  "event:imageURL": "https://firebasestorage.googleapis.com/v0/b/eventful-3d558.appspot.com/o/event_flyers%2Flilpump.jpg?alt=media&token=40c310d2-fe1e-49c4-b3a6-7419e6ef7ddd",
  "event:name": "lil pump performance",
  "event:price": 0,
  "event:promo": "https://firebasestorage.googleapis.com/v0/b/eventful-3d558.appspot.com/o/event_promo_vid%2FBEVT%2FTravis%20Scott_%20Houston%20Birds%20Eye%20View%20Tour%20Promo.mp4?alt=media&token=6d27d76e-281e-4083-a0ff-dbe2f25703e7",
  "event:state": "CA",
  "event:street:address": "2 Stockton St",
  "event:zip": 94108,
  "host_user": [
    "XwOBrK6zJXRG7wltV1QvoVXi6Jg1"
  ],
  "tags": [
    "hip hop",
    "concert"
  ],
  "_geoloc": {
    "lat": 37.7909427,
    "lng": -122.4084994
  },
  "objectID": "LPP"
}

If anyone can see where I went wrong please let me know!!!