Skip to content
New issue

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

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

Already on GitHub? # 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

@jexp jexp moved this to Todo in APOC Extended Larus Feb 22, 2024
@vga91 vga91 moved this from Todo to In Progress in APOC Extended Larus Mar 6, 2024
@vga91 vga91 moved this from In Progress to Review in APOC Extended Larus Mar 19, 2024
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
@github-project-automation github-project-automation bot moved this from Review to Done (to cherry-pick) in APOC Extended Larus May 16, 2024
vga91 added a commit that referenced this issue Nov 19, 2024
* Fixes #3937: Fully virtual graphs

* removed unused imports and updated extended.txt
vga91 added a commit that referenced this issue Nov 19, 2024
* Fixes #3937: Fully virtual graphs

* removed unused imports and updated extended.txt
@vga91 vga91 moved this from Done (to cherry-pick) to Done in APOC Extended Larus Nov 19, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
Development

No branches or pull requests

3 participants