SyntaxError: Unknown function 'algo.asNode'

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.

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

Algorithms Installation

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)"

also, did you restart after installation ?

can you post the full query and schema ?

1 Like

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 -

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.

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

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

Hey ameya,

Graph Algorithm version - 3.5.4.0

Apoc Algorithm version - 3.5.0.3

has algo.asNode

Thanks for the info.

Hello @sucheta can you assist me with the detailed information on the exact changes you made? For example which version of apoc and graphalgorithm jars did you replace with the previous ones in the plugins folder. I am facing the same problem and using Neo4j Desktop 1.1.10, existing Apoc (apoc-3.4.0.1), GraphAlgorithm (graphAlgorithms-3.4.0.0), GraphQL (graphQL-3.4.0.1). Thanks in anticipation.

Since you're using Neo4j Desktop, you should be able to go to the Plugins tab of the database instance in question, uninstall with a click the previously installed plugins, then the install button will install the latest version of the plugin that is correct for your version of Neo4j. If it doesn't install a new enough version, then the version of Neo4j you're using for that db instance is too old, and you'll want to either use a database instance with a newer Neo4j version (or upgrade your current version to a newer version) which will allow you to install newer versions of the plugins.