-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checkpoint: matches running, slight memory leak
- Loading branch information
1 parent
2608024
commit 87685b6
Showing
19 changed files
with
1,908 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Driver, EagerResult, Integer, Node } from "neo4j-driver"; | ||
import { GenericNodeShape } from "../types/NodeType"; | ||
import { GenericMatchToRelationshipType } from "../types/MatchToRelationshipType"; | ||
import dedent from "dedent"; | ||
|
||
|
||
|
||
|
||
export const upsertMatchesv2 = async ( | ||
neo4jDriver: Driver, | ||
fromNode: GenericNodeShape, | ||
matchToRelationshipType: GenericMatchToRelationshipType | ||
) => { | ||
// Run Query | ||
const matches = await neo4jDriver.executeQuery<EagerResult<{ | ||
score: number, | ||
matchToNode: Node<Integer, GenericNodeShape> | ||
}>>(dedent/*cypher*/` | ||
match (fromNode: ${fromNode.nodeType} {nodeId: $fromNode.nodeId})<-[:VECTOR_TO]-(fromNodeVectorNode:${fromNode.nodeType}Vector:${matchToRelationshipType.type}) | ||
call db.index.vector.queryNodes('${matchToRelationshipType.matchToNodeType.type}_vector', 5, fromNodeVectorNode.nodeTypeEmbedding) | ||
yield node as matchToVectorNode, score | ||
match (matchToNode: ${matchToRelationshipType.matchToNodeType.type} {nodeId: matchToVectorNode.nodeId}) | ||
merge (fromNode)-[match_to:MATCH_TO { type: $matchToType }]->(matchToNode) | ||
on create | ||
set | ||
match_to.fromNodeId = $fromNode.nodeId, | ||
match_to.type = $matchToType, | ||
match_to.toNodeId = matchToNode.nodeId, | ||
match_to.createdAt = timestamp(), | ||
match_to.updatedAt = timestamp(), | ||
match_to.score = score | ||
on match | ||
set match_to.updatedAt = timestamp(), | ||
match_to.score = score | ||
return score, matchToNode | ||
`, { | ||
fromNode, | ||
matchToType: matchToRelationshipType.matchToNodeType.type | ||
}).then(res => res.records.map(record => ({ | ||
score: record.get('score'), | ||
matchToNode: record.get('matchToNode').properties | ||
}))) | ||
|
||
console.log(matches) | ||
return matches | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.