Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-30-2020 11:32 PM
Hi Everyone,
I am facing some issues while working with JSON list . Please find my piece of code for reference.
list_json = [{json1}, {json2}.......]
query_q = ''' WITH ''' + list_json + ''' as value
UNWIND value as node
MATCH (e:t{txid: node.id}) SET e.tx_h = node.h '''
session.run(query_q )
Here i am not able to concat list with query
could anyone tell me what i am doing wrong and how can i do that
03-31-2020 07:27 AM
You need to pass list_json
as a parameter to your query, and not interpolate it into the string.
What you're trying to do is turn list_json into a big chunk of string cypher, which won't work. What you instead need to do is refer in the cypher query string to a parameter called list_json, and then pass it as an argument to session.run, so that the driver will do all of the interpolation for you.
Here's an example of appropriate parameter usage:
https://neo4j.com/docs/api/python-driver/current/#quick-example
03-31-2020 10:10 AM
Hi David,
Thanks for your reply. i will try this way as well.
but for the time being i want some help as well from you .
is there any limitation in neo4j regarding session creation ?
I am asking this thing because of below scenario:
i have around 10k jsons and i need to ingest these json data in neo4j. I am doing this with python.
i created a function which will fetch json one by one from source and pass this json in cypher
WITH apoc.convert.fromJsonMap(''' + data_json + ''') as value UNWIND value.tx as node MATCH (e:transaction{txid: node.txid}) # SET e.tx_hex = node.hex
now it is working fine for some 100 jsons but after 500 json file it is running the script but not inserting any data and not getting any error as well
could you please help me into this ?
03-31-2020 01:29 PM
This is the same situation in a slightly different form. Don't interpolate the text of data_json into a string and then ask APOC to parse it. Instead, send the JSON as a parameter into the cypher query.
04-01-2020 03:20 AM
Hi @david.allen ,
Thanks for your help . it seems working fine with parameter but could you please tell me how to speedup the process . currently it is taking 10 sec for 6 Mb json file with below query
WITH apoc.convert.fromJsonMap($param) as value
UNWIND value.tx as node
MATCH (e:transaction{txid: node.txid}) SET e.tx_hex = node.hex
04-03-2020 09:43 AM
please open a separate topic. Use the EXPLAIN feature to show what the query is doing -- and also please follow up with what else you've tried
All the sessions of the conference are now available online