Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-28-2020 04:26 AM
I'm trying to follow NLP Goes hand in hand with graphs. I'm hitting a problem when running apoc.periodic.iterate
with google's nlp api and wondered if somebody could shed some light on this?
In the article, we have loaded a dataset of 10,000 articles into Neo4j and we are trying to classify each article using Google NLP. apoc.nlp.gcp.classify.graph
e.g.
CALL apoc.periodic.iterate("
// get all articles
MATCH (node:Article) RETURN node
","
// classify each article
CALL apoc.nlp.gcp.classify.graph(node, {
// we retrieve gcp api key from static value storage
key: apoc.static.get('gcp.apiKey'),
// node property that contains the text
nodeProperty: 'content',
write:true
}) YIELD graph RETURN distinct 'done'",
{batchSize:10})
I receive an error from Neo4J
org.neo4j.graphdb.QueryExecutionException: Failed to invoke procedure `apoc.nlp.gcp.classify.graph`: Caused by: org.neo4j.graphdb.NotFoundException: Node[12510] is deleted and cannot be used to create a relationship
Interestingly, if I rerun the query, it is Node[12511]
that is deleted. Also, we receive the same error if the sub query is LIMIT
ed to 10 nodes.
When I run the query outside of apoc.periodic.iterate
(albeit on a reduced node count) it works fine. e.g.
MATCH (node:Article)
WITH collect(node)[..10] AS articles
CALL apoc.nlp.gcp.classify.graph(articles, {
// we retrieve gcp api key from static value storage
key: apoc.static.get('gcp.apiKey'),
// node property that contains the text
nodeProperty: 'content',
write:true
}) YIELD graph as g RETURN g
Profile:
Neo4j desktop Version 1.3.3 (1.3.3.24)
DBMS: Version: 4.1.0
apoc-nlp-dependencies-4.0.0.17.jar
03-16-2022 08:00 AM
I have the same situation!! Don't know how to solve
06-16-2022 02:33 AM
I am facing the same issue when I run the below query it runs fine ``
MATCH (node:Article)
WITH collect(node)[..10] AS articles
CALL apoc.nlp.gcp.classify.graph(articles, {
// we retrieve gcp api key from static value storage
key: apoc.static.get('gcp.apiKey'),
// node property that contains the text
nodeProperty: 'content',
write:true
}) YIELD graph as g RETURN g
but when I run
CALL apoc.periodic.iterate("
// get all articles
MATCH (node:Article) RETURN node
","
// classify each article
CALL apoc.nlp.gcp.classify.graph(node, {
// we retrieve gcp api key from static value storage
key: apoc.static.get('gcp.apiKey'),
// node property that contains the text
nodeProperty: 'content',
write:true
}) YIELD graph RETURN distinct 'done'",
{batchSize:10})
``
I get the error. Stuck here any help would be highly appreciated
{
"total": 1051,
"committed": 0,
"failed": 1051,
"errors": {
"org.neo4j.graphdb.QueryExecutionException: Failed to invoke procedure `apoc.nlp.gcp.classify.graph`: Caused by: org.neo4j.graphdb.NotFoundException: Node[11601] is deleted and cannot be used to create a relationship": 1,
06-17-2022 02:17 AM
@hempnall @jrxavier @jatinjaitleypro
I think you should rebind the nodes, that is returning the id of nodes and match via id in the 2nd query, see here: https://neo4j.com/developer/kb/a-significant-change-in-apoc-periodic-iterate-in-apoc-4-0/
Therefore, in your case, this should work (changing "<CONFIG>" with your config):
CALL apoc.periodic.iterate("
// get all articles
MATCH (node:Article) RETURN id(node) as id
","
// classify each article
MATCH (node) where id(node) = id
CALL apoc.nlp.gcp.classify.graph(node, {<CONFIG>}) YIELD graph RETURN distinct 'done'",
{batchSize:10})
06-20-2022 05:17 AM
I've reported the issue. It seems to be a combination of apoc periodic iterate and apoc NLP procedures:
https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/2998
All the sessions of the conference are now available online