Closed spinach closed 4 years ago
Follows similar API as the JS related Item widget.
This is how the DX looks, using keypath for specifying the score for each optional filter
struct Product: Codable { let name: String let brand: String let type: String let categories: [String] let image: URL } let matchingPatterns: [MatchingPattern<Product>] = [ MatchingPattern(attribute: "brand", score: 3, filterPath: \.brand), MatchingPattern(attribute: "type", score: 10, filterPath: \.type), MatchingPattern(attribute: "categories", score: 2, filterPath: \.categories), ] let searcher = SingleIndexSearcher(index: .test) let product = Product.init() let hitsInteractor = HitsInteractor<JSON>.init() let hit: Hit<Product> = .init(objectID: "objectID", object: product) hitsInteractor.connectSearcher(searcher, withRelatedItemsTo: hit, with: matchingPatterns) searcher.search()
Follows similar API as the JS related Item widget.
This is how the DX looks, using keypath for specifying the score for each optional filter