我收集了以下数据:
"docs":[
{"EventDate":"2019-01-29T00:03Z",
"type":"Request",
"RqID":"00000000000000000000000000000001"},
{"EventDate":"2019-01-29T00:04Z",
"type":"Response",
"RqID":"00000000000000000000000000000001"},
{"EventDate":"2019-01-29T01:45Z",
"type":"Request",
"RqID":"00000000000000000000000000000002"},
{"EventDate":"2019-01-29T01:45Z",
"type":"Response",
"RqID":"00000000000000000000000000000002"},
]
我想计算“响应请求”时间。在SQL中,我这样做的方法是:
select rq, t2.EventType-t1.EventType from table t1, table t2
where t1.RqID = t2.RqID
and t1.type = 'Request'
and t2.type = 'Response'
加入solr返回我未加入文档。如何在Solr中做到这一点?
答案 0 :(得分:1)
如果您首先使用rqID group the data,然后将scalar math sub function与响应中的EventDate-请求中的EventDate结合使用,则应该得到想要的结果。
答案 1 :(得分:0)
我可以加入: q =类型:“请求”&fl = *,resp [subquery]&resp.q = {!term f = RqID v = $ row.RqUID}&resp.fq =响应
但是我不知道如何计算持续时间。