该DynamicRangeFilter在Searchkit是一个很好的和简单的解决方案如滤波器年.您只需在Elasticsearch中保存一年字段并使用过滤器:
<DynamicRangeFilter
field="year"
id="year"
title="Year"
/>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我还没有找到如何使用它来过滤多值属性,例如一系列年份.想象一下,你有一个持续时间属性a start和end:
[
{
"id": 123,
"title": "Foo",
"duration": {
"start": 2013,
"end": 2016
}
},
{
"id": 234,
"title": "Bar",
"duration": {
"start": 2015,
"end": 2015
}
},
{
"id": 345,
"title": "Baz",
"duration": {
"start": 2017,
"end": 2020
}
}
]
Run Code Online (Sandbox Code Playgroud)
现在,过滤器应该尊重持续时间并显示范围内的所有项目.我不确定是否以及如何使用fieldOptions来实现这一目标.