Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully virtual graphs #3937

Closed
jexp opened this issue Feb 1, 2024 · 0 comments
Closed

Fully virtual graphs #3937

jexp opened this issue Feb 1, 2024 · 0 comments

Comments

@jexp
Copy link
Member

jexp commented Feb 1, 2024

`apoc.virtual.graph([list-of-paths, nodes, rels], [properties to remove]) -> {nodes, rels}

  • to exclude embeddings and large text properties
  • we already have all the virutal graph methods but they actually just wrap existing nodes and rels
call db.index.fulltext.queryNodes("movieFulltext","Forrest Gump", {limit:1}) yield node as n, score as s1
call db.index.vector.queryNodes("moviePlotsEmbedding",5, n.plotEmbedding) yield node as movie, score
match path = (person:Person)-[rp]->(movie)-[rg:IN_GENRE]->(genre)

with collect(path) as paths
call apoc.graph.fromPaths(paths,"results",{}) yield graph
with graph.nodes as nodes, graph.relationships as rels
with rels, apoc.map.fromPairs([n in nodes | [coalesce(n.tmdbId, n.name), apoc.create.vNode(labels(n),n {.*, plotEmbedding:null, posterEmbedding:null, plot:null, bio:null })]]) as nodes
return nodes, [r in rels | apoc.create.vRelationship(nodes[coalesce(startNode(r).tmdbId,startNode(r).name)], type(r), properties(r), nodes[coalesce(endNode(r).tmdbId,endNode(r).name)])] as rels

I want to replace the whole thing by an aggregation function like this:

call db.index.fulltext.queryNodes("movieFulltext","Forrest Gump", {limit:1}) yield node as n, score as s1
call db.index.vector.queryNodes("moviePlotsEmbedding",5, n.plotEmbedding) yield node as movie, score
match path = (person:Person)-[rp]->(movie)-[rg:IN_GENRE]->(genre)
return apoc.graph.filterProperties(path, ['plotEmbedding', 'posterEmbedding','plot', 'bio'])

so basically we create the same graph object with the extract that we have for the virtual graph
and then go over the nodes and replace the ones that have one of the properties with virtual ones that wrap the original nodes and leave off the properties

vga91 added a commit that referenced this issue Apr 8, 2024
vga91 added a commit that referenced this issue Apr 8, 2024
vga91 added a commit that referenced this issue Apr 16, 2024
RobertoSannino pushed a commit that referenced this issue Apr 17, 2024
* Fixes #3937: Fully virtual graphs

* removed unused imports and updated extended.txt
@vga91 vga91 closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done (to cherry-pick)
Development

No branches or pull requests

3 participants