Import json in neo4j and create relationship for Item Recommendation

Hi all,
I have a json file containing array of objects
Sample records from file is as below:
Item JSON,
[
{
"id": "1",
"name": "Pizza"
},
{
"id": "2",
"name": "Coke"
},
{
"id": "3",
"name": "Burger"
}
]

Order JSON, (the OrderedItems says Pizza and coke are brought together)
[
{
"OrderedItems": [
{
"id": "1",
"name": "Pizza"
},
{
"id": "2",
"name": "Coke"
}
]
},
{
"OrderedItems": [
{
"id": "3",
"name": "Burger"
},
{
"id": "1",
"name": "Pizza"
},
{
"id": "2",
"name": "Coke"
}
]
}
]

I need to create relationships between these objects can someone help me out,
My logic follows:
I will pass an item from the item object to the order JSON object it iterates through the all the ordered items in the object gives result as below,

If I pass Pizza, it gives output as Pizza ->(Ordered_with)-> Coke (Here two times pizza ordered with coke)
If I pass Burger, it gives output as Burger ->(Ordered_with)-> Coke
If I pass Coke, it gives output as Coke ->(Ordered_with)-> Pizza, Burger.

Thanks in advance :slight_smile:

First of all you need to use apoc.load.json to create nodes and relationship between these items .

After that write these logic into your cypher .

please let us know if you require help in writing cypher

Thanks much for your reply @12kunal34
I have used apoc.load.json to create nodes
// import item_details
WITH "file:///item_details.json" AS url

CALL apoc.load.json(url) YIELD value as item
MERGE (i:Item {item_id: item.id})
SET i.name = item.name

But how to create relationship between ordered items while importing,
I am struggling a bit could you please help me out?

Below is the half written query,
// import line_item_details
WITH "file:///orders.json" AS url
CALL apoc.load.json(url) YIELD value
WITH value.OrderedItems AS OrderedItems
FOREACH (OrderedItem IN OrderedItems |
MERGE (o:OrderedItems {item_id: OrderedItem.id}) // How to create relationship here?
);