从值字符串创建 refinementList
Create refinementList from string of values
我的数据结构如下:
{
"id": 12345,
"name": "Brother PJ-663 Direct A4 Thermal Mobile Printer",
"type": "Thermal printer",
"features": "USB, Mobile Print"
},
我正在尝试根据功能字符串(分解)中的值创建一个 refinementList 小部件,就像我为类型所做的一样,但我不确定这是否是正确的方法,甚至可能。
我应该如何格式化数据才能创建单个 instantsearch.widgets.refinementList 小部件?
我也改用 _tags 并将这些功能中的每一个添加为标签,是否可以实现此目的?
最好的方法是在索引之前重新格式化(按 ,
拆分)数据并将 features
和 type
索引为数组:
{
"id": 12345,
"name": "Brother PJ-663 Direct A4 Thermal Mobile Printer",
"type": [
"Thermal printer"
],
"features": [
"USB",
"Mobile Print"
]
}
然后在 Algolia 设置中将这些属性设置为分面属性,就可以了。您可以使用 instantsearch.js's refinementList widget 根据这些属性过滤结果。
我不会在这里选择 _tags
,因为您有 2 个不同的属性要用于过滤,而 _tags
不允许您以简单的方式进行过滤。
我的数据结构如下:
{
"id": 12345,
"name": "Brother PJ-663 Direct A4 Thermal Mobile Printer",
"type": "Thermal printer",
"features": "USB, Mobile Print"
},
我正在尝试根据功能字符串(分解)中的值创建一个 refinementList 小部件,就像我为类型所做的一样,但我不确定这是否是正确的方法,甚至可能。
我应该如何格式化数据才能创建单个 instantsearch.widgets.refinementList 小部件?
我也改用 _tags 并将这些功能中的每一个添加为标签,是否可以实现此目的?
最好的方法是在索引之前重新格式化(按 ,
拆分)数据并将 features
和 type
索引为数组:
{
"id": 12345,
"name": "Brother PJ-663 Direct A4 Thermal Mobile Printer",
"type": [
"Thermal printer"
],
"features": [
"USB",
"Mobile Print"
]
}
然后在 Algolia 设置中将这些属性设置为分面属性,就可以了。您可以使用 instantsearch.js's refinementList widget 根据这些属性过滤结果。
我不会在这里选择 _tags
,因为您有 2 个不同的属性要用于过滤,而 _tags
不允许您以简单的方式进行过滤。