Constructing e-commerce interest mapping can be divided into three stages: data modeling → mapping construction → query application:
Data modeling phase
- Define the node type:
User,Product,Behavior(Click/Favorite/Buy) - Designing relationships with timestamps:
VIEWED_AT,PURCHASED_ON
Example of map construction
graph = Graphiti()
# 添加用户节点
graph.add_node("User",
user_id="U123",
name="Alice",
demographics="female_25_35")
# 添加商品节点
graph.add_node("Product",
sku="P789",
category="running_shoes",
brand="Adidas")
# 添加带时间的行为关系
graph.add_edge("U123", "VIEWED", "P789",
timestamp="2023-05-15T14:30:00",
session_duration=120)
Typical Query Scenarios
- Real-time recommendations::
MATCH (u:User)-[r:VIEWED|PURCHASED]->(p:Product) WHERE r.timestamp > datetime()-7d RETURN p.sku - Analysis of the evolution of interests: Trends in user category preferences by quarter
- Cross-User Recommendations: Discovering similar user groups through graph algorithms
Actual cases show that the adoption of this program can make e-commerce CTR increase by 15-20%, mainly due to the accurate interest capture in the time dimension.
This answer comes from the articleGraphiti: dynamic knowledge graph construction and query tool (time-aware long memory scheme)The































