Improve performance with pattern comprehensions

@Mogge @mattwr18 this is how you can eagerly fetch resources
This commit is contained in:
roschaefer 2019-12-20 20:13:02 +01:00
parent b3521d8ce5
commit f1b581aa86

View File

@ -10,12 +10,23 @@ export default {
const postCypher = `
CALL db.index.fulltext.queryNodes('post_fulltext_search', $query)
YIELD node as resource, score
MATCH (resource)<-[:WROTE]-(user:User)
MATCH (resource)<-[:WROTE]-(author:User)
WHERE score >= 0.5
AND NOT (user.deleted = true OR user.disabled = true
OR resource.deleted = true OR resource.disabled = true
OR (:User { id: $thisUserId })-[:BLOCKED]-(user))
RETURN resource {.*, __typename: labels(resource)[0]}
AND NOT (
author.deleted = true OR author.disabled = true
OR resource.deleted = true OR resource.disabled = true
OR (:User { id: $thisUserId })-[:BLOCKED]-(author)
)
WITH resource, author,
[(resource)<-[:COMMENTS]-(comment:Comment) | comment] as comments,
[(resource)<-[:SHOUTED]-(user:User) | user] as shouter
RETURN resource {
.*,
__typename: labels(resource)[0],
author: properties(author),
commentsCount: toString(size(comments)),
shoutedCount: toString(size(shouter))
}
LIMIT $limit
`