SyntaxError: Unknown function 'algo.asNode'

cypher
knowledge-base
(Sucheta) #1

Hi,

While implementing this particular query from Jaccard Similiarity algorithm -

MATCH (p:Organization)-->(cuisine)
WITH {item:id(p), categories: collect(id(cuisine))} as userData
WITH collect(userData) as data
CALL algo.similarity.jaccard.stream(data)
YIELD item1, item2, count1, count2, intersection, similarity
RETURN algo.asNode(item1).name AS from, algo.asNode(item2).name AS to, intersection, similarity
ORDER BY similarity DESC

Neo.ClientError.Statement.SyntaxError: Unknown function 'algo.asNode' (line 6, column 8 (offset: 251))
"RETURN algo.asNode(item1).name AS from, algo.asNode(item2).name AS to, intersection, similarity"

Please guide.

0 Likes

(DKumar) #2

have you installed the library ?
A detailed installation for Neo4j Desktop and Server is available in

Algorithms Installation

0 Likes

(Sucheta) #3

I have added the Graph algorithms in my Neo4j desktop . And when i run -
CALL algo.list()

I get the list but it doesn't have algo.asNode .

Error -

Neo.ClientError.Statement.SyntaxError: Variable asNode not defined (line 1, column 16 (offset: 15))
"CALL algo.list(asNode)"

0 Likes

(DKumar) #4

also, did you restart after installation ?

can you post the full query and schema ?

0 Likes

(Sucheta) #5

Hi,

The dummy schema is ->

//Company

CREATE (ic:Company { name: "IC", dealing: "Banking" })

//Department
Match (ic:Company) WHERE icici.name="IC"
Create (it:Department {name:"IT", company:"IC"}),
(ic)-[:Department]->(it)

//System
Match (it:Department) WHERE it.name="IT"
Create (mobile:System {name:"Mobile", company:"IC"}),
(it)-[:System]->(mobile)

And Query is -

MATCH (p)-[*]->(ic) WITH {item:id(p), categories: collect(id(ic))} as userData WITH collect(userData) as data CALL algo.similarity.jaccard.stream(data) YIELD item1, item2, count1, count2, intersection, similarity RETURN algo.asNode(item1).name AS from, algo.asNode(item2).name AS to, intersection, similarity ORDER BY similarity DESC

Image -

0 Likes

(Andrew Bowman) #6

Which version of Neo4j and which version of the Graph Algo library do you have installed? It could be that you are using a version before this function was added.

0 Likes