Ama*_*a K 2 json firebase reactjs firebase-realtime-database algolia
我是Algolia搜索的新手.我的设置是React和Firebase,我的Firebase用户表在Algolia中被编入索引.我正在使用refinementList小部件和标签来允许用户更好地过滤,但我想知道是否有一种方法可以将字段中的单词分开作为单独的细化.例如:
colors: "red, blue, green, white"
Run Code Online (Sandbox Code Playgroud)
有没有办法构建我的数据,将这些颜色作为refinementList或标签云中的单独项目?我尝试使用括号,我在另一个堆栈溢出帖子中看到的一种技术,但这不起作用.谢谢!
Algolia使用数组,因此解决方案是colors: "red, blue, green, white"改为colors: ["red, "blue", "green", "white"],你可以用
var colors = "red, blue, green, white,value with space"
var splitColors = colors.split(/[,]+/).map(str=>str.trim())
Run Code Online (Sandbox Code Playgroud)
然后你可以在Algolia上splitColors作为colors属性推送
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |