0

我在下面尝试了全文索引,如下所示

CALL db.index.fulltext.queryNodes("index1", "x") YIELD node as node1, score as score1
With collect({id: node1.id, score: score1}) as rows1
CALL db.index.fulltext.queryNodes("index2", "name:Y") YIELD node as node2, score as score2
With collect({id: node2.id, score: score2}) as rows2, rows1
return rows1 + rows2 as final

如果两者都有一些记录,则上面的返回结果,如果 node2 没有任何匹配的结果,那么即使 node1 的结果很少,最终结果也是空的。

我的要求是结合或联合符合任何条件的两者。你能帮我实现这一目标吗?

提前致谢。

4

1 回答 1

0

如果索引查找失败,那么您将无法取回任何行(并且该行的先前数据被清除),这可能会使您的查询短路。您可能想尝试两个结果的 UNION:

CALL db.index.fulltext.queryNodes("index1", "x") YIELD node, score
RETURN node, score
UNION
CALL db.index.fulltext.queryNodes("index2", "name:Y") YIELD node, score
RETURN node, score
于 2020-01-23T00:29:54.400 回答