从 Neo4j 获取每组最重要的搜索结果
Getting topmost search result per group from Neo4j
我正在使用 Neo4j 的全文搜索功能来获得与输入的搜索字符串列表最接近的匹配技巧。下面在密码查询中。
UNWIND ["nursing care requirements", "relatives tutoring student nurses", "blood pressures", "emotional support", "intravenous infusions", "junior staff", "patient samples", "pulses", "workloads"] AS x
CALL db.index.fulltext.queryNodes("full-text-skills", x) YIELD node, score
RETURN x, node.name, score
它运行良好并且 return 所有匹配结果(上面的例子有 1000 行)。现在我想获取由 db.index.fulltext.queryNodes
编辑的 score
属性 return 最匹配的技能(列表中每个输入项 1 行)。我尝试在 return
语句后添加限制,但它限制了整个输出。我真正想要的是限制输入列表中每个项目的搜索结果。
我终于找到了解决上述问题的方法。我们可以使用 collect 来收集每组的结果,并且根据限制我们可以获得每组的结果。密码查询将是 -
UNWIND ["nursing care requirements", "relatives tutoring student nurses", "blood pressures", "emotional support", "intravenous infusions", "junior staff", "patient samples", "pulses", "workloads"] AS x
CALL db.index.fulltext.queryNodes("full-text-skills", x) YIELD node, score
RETURN x,collect(node.name)[0..3]
我们有一篇关于 limiting MATCH results per row 的知识库文章应该可以帮助您解决问题,并且包含您找到的获取部分收集结果的方法。
我正在使用 Neo4j 的全文搜索功能来获得与输入的搜索字符串列表最接近的匹配技巧。下面在密码查询中。
UNWIND ["nursing care requirements", "relatives tutoring student nurses", "blood pressures", "emotional support", "intravenous infusions", "junior staff", "patient samples", "pulses", "workloads"] AS x
CALL db.index.fulltext.queryNodes("full-text-skills", x) YIELD node, score
RETURN x, node.name, score
它运行良好并且 return 所有匹配结果(上面的例子有 1000 行)。现在我想获取由 db.index.fulltext.queryNodes
编辑的 score
属性 return 最匹配的技能(列表中每个输入项 1 行)。我尝试在 return
语句后添加限制,但它限制了整个输出。我真正想要的是限制输入列表中每个项目的搜索结果。
我终于找到了解决上述问题的方法。我们可以使用 collect 来收集每组的结果,并且根据限制我们可以获得每组的结果。密码查询将是 -
UNWIND ["nursing care requirements", "relatives tutoring student nurses", "blood pressures", "emotional support", "intravenous infusions", "junior staff", "patient samples", "pulses", "workloads"] AS x
CALL db.index.fulltext.queryNodes("full-text-skills", x) YIELD node, score
RETURN x,collect(node.name)[0..3]
我们有一篇关于 limiting MATCH results per row 的知识库文章应该可以帮助您解决问题,并且包含您找到的获取部分收集结果的方法。