如何过滤algolia中的类别的结果?

时间:2018-02-26 05:14:05

标签: ios swift algolia

这里我使用algolia来显示所选类别的数据,以便根据它传递和加载列表页面中的数据,这里我将所选数据传递到列表页面,但是这里无法加载所选类别所需的数据并获得在index.search一行崩溃了,任何人都可以帮我解决这个问题吗?

这是我选择的构面过滤器数组数据,我从我的类别页面

传递
  

[" [categories.level0:Men]"," [categories.level1:Men /// Tops]"]   [categories.level2:男性///上装///三通]

以下是我的facets数组数据

["categories.level0", "categories.level1", "categories.level2", "gometoo_seller", "style_bottom", "climate", "sleeve", "gender", "category_gear", "eco_collection", "pattern", "collar", "style_bags", "style_general", "is_trending", "erin_recommends", "format", "performance_fabric", "strap_bags", "features_bags", "activity", "material", "categories", "color", "is_new", "size", "price", "manufacturer", "price.BHD.default", "price.EGP.default", "price.EUR.default", "price.KWD.default", "price.OMR.default", "price.SAR.default", "price.USD.default", "price.AED.default"]

这是我的algolia数据图片

enter image description here

这是我的algolia后端数据

index.search("", {
 "hitsPerPage": "10",
 "page": "0",
 "analytics": "false",
 "attributesToRetrieve": "*",
 "facets": "[\"categories.level0\",\"categories.level1\",\"categories.level2\",\"activity\",\"category_gear\",\"climate\",\"color\",\"eco_collection\",\"erin_recommends\",\"features_bags\",\"format\",\"gender\",\"gometoo_seller\",\"is_new\",\"is_trending\",\"material\",\"pattern\",\"performance_fabric\",\"price.AED.default\",\"price.BHD.default\",\"price.EGP.default\",\"price.EUR.default\",\"price.KWD.default\",\"price.OMR.default\",\"price.SAR.default\",\"price.USD.default\",\"size\",\"strap_bags\",\"style_bags\",\"style_bottom\",\"style_general\"]",
 "facetFilters": "[[\"categories.level2:Men /// Tops /// Tees\"],[\"categories.level1:Men /// Tops\"],[\"categories.level0:Men\"]]"
});

并且代码是

if (self.appId != nil && self.apiKEY != nil && self.Indices != nil) {
            InstantSearch.shared.configure(appID: "\(self.appId!)", apiKey: "\(self.apiKEY!)", index: "\(self.Indices!)en_products")
            InstantSearch.shared.params.attributesToRetrieve = ["*"]
            InstantSearch.shared.registerAllWidgets(in: self.view)
            let query = Query()
            query.facets = facetsArray
            query.facetFilters = categoriesArray
            index.search(query, completionHandler: { (res, error) in
                self.listCollectionView.reloadData()
            })
            hitsCollectionViews = [self.listCollectionView]
            ActivityIndicator.stopAnimating()  
        }

0 个答案:

没有答案