当我在索引上调用db.index.fulltext.queryNodes()时,我可以对结果运行另一个全文查询吗?我需要搜索我的数据库中的7-8个不同的属性跨越不同的标签与每个属性的不同搜索参数。我该怎么做呢?如果我使用reduce()函数或apoc.coll.intersection并尝试获得一个交集,例如...
CALL db.index.fulltext.queryNodes("first_name", "manas~")
YIELD node as first_names
WITH collect(first_names) as first_name_list
CALL db.index.fulltext.queryNodes("aliases", "boncha~")
YIELD node as aliases
WITH collect(aliases) as alias_list,first_name_list
RETURN apoc.coll.intersection(first_name_list, alias_list) AS output
LIMIT 5这不会导致内存膨胀吗?
发布于 2021-04-12 03:07:10
如果使用Neo4j 4.1+,最好使用subqueries:
CALL {
CALL db.index.fulltext.queryNodes("first_name", "manas~")
YIELD node, score
RETURN node, score
UNION ALL
CALL db.index.fulltext.queryNodes("aliases", "boncha~")
YIELD node, score
RETURN node, score
}
RETURN node, sum(score) AS totalScore
ORDER BY totalScore DESC对于交叉点,您可以计算每个节点有多少个匹配,因此如果它们在两个查询中匹配,则将计数为2:
CALL {
CALL db.index.fulltext.queryNodes("first_name", "manas~")
YIELD node, score
RETURN node, score
UNION ALL
CALL db.index.fulltext.queryNodes("aliases", "boncha~")
YIELD node, score
RETURN node, score
}
WITH node, count(*) AS matches, sum(score) AS totalScore
WITH node, matches, totalScore
WHERE matches = 2
ORDER BY totalScore DESC
RETURN node, totalScorehttps://stackoverflow.com/questions/67030472
复制相似问题