After having attended the Graph Modeling class, I'm looking to optimize a graph I'm using that tracks product expiration dates. Originally I had the expiration date as a property of the product, but in reviewing the materials from the Graph Modeling class, it seems to make sense to create an Expiration Date node. not only for performance reasons, but also to show additional clusters of products expiring. I can obviously create an Expiration Date node with a year value, but I'm looking at a year and month (YYYY-MM). Does this make sense?
Secondly, I'm having issues extracting just the year and month from the existing date field (actual date) to use for the new Expiration Date node. Any suggestions on approaches for just this format?
I found a partial solution by using a ".year" on the end of my date property to just return the year. Is there a way to make it year and month? The source property is a date type (YYYY-MM-DD).
I'm pulling the date from the product node (actual date, not a string representation) and then creating a new date node with just the year and month. The solution I had wasn't elegant but it worked for what I needed. I can now see all the products related to a date node. It traverses quicker than just using a date property in the Product node and pattern (things expiring in the same time frame) now shows up with the relationship.
This is the script I used:
MATCH (p:PRODUCT)
MERGE (eos:EOS_DATE {EOS_Date: toString(p.EOS_Date.year) + '-' + toString(p.EOS_Date.month)})
MERGE (p)-[:END_OF_SUPPORT]->(eos)
RETURN eos, p