Client(appID: "YourApplicationID", apiKey: "YourAPIKey") let index = client.index(withName: "users") index.search(Query(query: "tarou")) { (response, error) in if let response = response { print("Result: \(response)") } }
typealias HitType = User let page: Int let per: Int let text: String? let hashtags: [String]? var indexName: String { return "user" } var query: AlgentQuery { let query = AlgentQuery(query: text) query.page = UInt(page) query.hitsPerPage = UInt(per) if let hashtags = hashtags { query.tagFilters = hashtags } return query } }
0, per: 20, text: "", hashtags: []) Algent.shared.search(request: request) { result in switch result { case .success(let response): // AlgoliaResponse<Request.HitType> print(response.hits) // see hit object case .failure( let error): print(error) } }