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 ic.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

(Sucheta) #7

Thanks Andrew !. I replaced the
[1]
apoc and graph algorithm jars from plugins folder of neo4j and even made changes in the

[2] neo4j config file - neo4j.conf -

dbms.security.procedures.unrestricted=algo.*,apoc.*
0 Likes

(Ameyasoft) #8

I also see that algo.asNode is missing in the algorithms library. Checked versions 3.5.0.1 and 3.5.4.0. Desktop version 1.1.21 and browser 3.2.19. Please let us know which algorithms version has algo.asNode(s).
Thanks

0 Likes

(Sucheta) #9

Hey ameya,

Graph Algorithm version - 3.5.4.0

Apoc Algorithm version - 3.5.0.3

has algo.asNode

0 Likes

(Ameyasoft) #10

Thanks for the info.

0 Likes