Solr 中具有不同 gaps/steps 的范围方面
Range facet with different gaps/steps in Solr
目前请求是
{
"query": "*:*",
"facet": {
"prices": {
"type": "range",
"field": "price",
"start": 0,
"end": 100,
"gap": 20
}
}
}
我需要检索范围的计数
0 TO 5
5 TO 10
10 TO 20
20 TO 30
30 TO 40
40 TO 50
50 TO 100
100 TO ?(NO END)
检索这些范围的计数的请求应该如何处理?
range parameters listing shows you the available parameters 及其含义。要获得 5
作为差距,请使用 "gap": 5
。要获取范围之外的条目,请包括 "other": "after"
:
"type": "range",
"field": "price",
"start": 0,
"end": 100,
"gap": 5,
"other": "after"
对于您的自定义范围,您需要 include the ranges explicitly。您不能将 other
与 range
一起使用,但有一些解决方法:
"ranges": [
{"range": "[0, 5)"},
{"range": "[5, 10)"},
{"range": "[10, 20)"},
{"range": "[20, 30)"},
{"range": "[30, 40)"},
{"range": "[40, 50)"},
{"range": "[50, 100)"},
{"range": "[100, *]"},
]
目前请求是
{
"query": "*:*",
"facet": {
"prices": {
"type": "range",
"field": "price",
"start": 0,
"end": 100,
"gap": 20
}
}
}
我需要检索范围的计数
0 TO 5
5 TO 10
10 TO 20
20 TO 30
30 TO 40
40 TO 50
50 TO 100
100 TO ?(NO END)
检索这些范围的计数的请求应该如何处理?
range parameters listing shows you the available parameters 及其含义。要获得 5
作为差距,请使用 "gap": 5
。要获取范围之外的条目,请包括 "other": "after"
:
"type": "range",
"field": "price",
"start": 0,
"end": 100,
"gap": 5,
"other": "after"
对于您的自定义范围,您需要 include the ranges explicitly。您不能将 other
与 range
一起使用,但有一些解决方法:
"ranges": [
{"range": "[0, 5)"},
{"range": "[5, 10)"},
{"range": "[10, 20)"},
{"range": "[20, 30)"},
{"range": "[30, 40)"},
{"range": "[40, 50)"},
{"range": "[50, 100)"},
{"range": "[100, *]"},
]