neo4j - 如何汇总分数
问题描述
我有这个密码查询:
CALL db.index.fulltext.queryNodes("names","John Snow") YIELD node, score
WITH node, score MATCH (node)-[c:ACTIVE]->() WHERE c.is_active = 'True'
RETURN DISTINCT node, score ORDER BY score DESC LIMIT 10
我想根据分数百分比过滤结果,所以可能我需要percentileDisc() as pd
聚合然后WHERE score > pd
子句。我如何在这里应用它?percentileDisc(score, 0.5)
总是给自己打分。
解决方案
这应该有效:
CALL db.index.fulltext.queryNodes("names","John Snow") YIELD node, score
WHERE EXISTS ((node)-[:ACTIVE {is_active: 'True'}]->())
WITH COLLECT({node: node, score: score}) AS data, percentileDisc(score, 0.5) AS p
UNWIND data AS d
WITH p, d
WHERE d.score > p
RETURN p, d.node AS node, d.score AS score
ORDER BY score DESC LIMIT 10
推荐阅读
- api-platform.com - 使用 GraphQL 在 ApiPlatform 上使用自定义解析器/数据提供程序返回集合
- vue.js - 使用 iframe 进行 Vuetify 对话框
- r - 用 lapply 替换多个数据帧中的字符串
- r - R c() "combine-function",不通过第一个输入设置类
- .net - 当另一个用户给你写信时,如何在 React 聊天应用程序中实时更新未读消息计数器
- reactjs - 意外的令牌,应为“;” 在本机反应
- python - Python - 设置数组
- flutter - 在 VS Code 中更改 Flutter 热重载时间
- javascript - 如何让 for 循环检查第一行
- python - 为 numpy 数组自动创建切片范围