cancel
Showing results for 
Search instead for 
Did you mean: 

Property with apoc.map as data structure

tideon
Graph Buddy

Dear Everyone,

Neo4J 4.0
Browser Desktop 4.0.3
Operating system OSX Mojave

I have been reading about the use of Apoc maps for about a week, but none of the stuff I have watched or read actually use it in the query.

This page https://neo4j.com/docs/labs/apoc/3.5/data-structures/map-functions/
gives examples of it with the return clause, but doesn't show me how to add it to a node as a property.

What I want to do is that the following.

I have an invoice that has sub invoices attached to it, so what I need to do is add the sub invoices as a a map in one of the properties.

The invoice is a reminder invoice so I want to add the two invoices to the node in a map in a variable, but the original invoices that are in the map I want to add as external nodes, The reason being to keep track of the originals in comparison to what they send on the reminder invoices. Will be used for comparisons down the line.

The information in the map will be key value pairs. I just don't understand as yet how to add the map to a property on a node. And also how to edit it later. I did read that Neo4J doesn't do edits on maps, so that is why I went and looked at APOC.

So here is a little example of what the data from the invoice looks like

InvoiceRefNR:1, Date:"09-02-2006", PricipalCost:33
InvoiceRefNR:2, Date:"04-01-2006", PricipalCost:456

How do I add this information to the node as a property with the name InvoiceRefNR

So the main node is:
Label: Invoice
Property: RefNr
Property: SubInv: (this will / needs to be a map of all the sub invoices)

I need to be able to access each sub invoice as it's own map. So I am alreay wondering if this will be a list of maps inside the SubInv property.

Bear in mind I am new to this, so the more detailed your explanation the better.

Thank you in advance.
Tideon

6 REPLIES 6

intouch_vivek
Graph Steward

Hi Tideon.

Could you please give sample dataset with Invoice, subinvoice and their properties and relationships.

Regards
Vivek

Hello Vivek,

Thank you for responding. How would I do that?

Do you mean for me to write it out?

Kind regards,
Tideon

Hi Tideon,

If you provide me sample dataset and exact requirement that will be help me to visualize and apply the logic

Regards
Vivek

Hello Vivek,

What are the steps to create the dataset?

I'm still new to Neo4J.

Kind regards,
Tideon

Hi Tideon,
You cannot set a map as property on node. That's not supported. You need to convert it to string and set it as a property. When you are reading you can convert it back to map.

See the documentation

https://neo4j.com/docs/labs/apoc/current/overview/

Methods to look at

apoc.convert.setJsonProperty

apoc.convert.getJsonProperty

@tideon , Yes @anthapu is correct we cannot create map as node/relationship property.

However if you provide the sample csv file/json file that you are trying to insert and tell us the exact requirement then hopefully we can assist you

Regards
Vivek