douzi5214 2017-02-06 15:47
浏览 104
已采纳

最初未知时在neo4j中建模关系

I currently have some code that looks through various datasets and models electronic relationships between them. E.g., JSESSIONID.

I would like to model each user's interactions with an application where they have to submit unique identifiers. E.g., email address.

In processing logs of the application, I see emailA@host.com use the application with JSESSIONID asdfghjkl. I then see emailB@host.com also use the applcation with JESSIONID asdfghjkl. Finally, I see emailB@host.com use JSESSIONID qwertyuiop.

In my go code, it's easy for me to process the logs and write out both emailA@host.com and emailB@host.com as Nodes and then write the JSESSIONID relationship between them.

MERGE (a:EMAIL {label:userA@host.com}) MERGE (b:EMAIL {label:userB@host.com}) MERGE (a)-[:asdfghjkl]-(b)

However, I don't know the best way to do this at scale. (i.e., Application logs are 1TB in size). The limitation is memory -- I can't find all email addresses that use asdfghjkl as a SessionIDs without processing all the data, so I can't write out the relationship between them due to memory constraints.

What I would really like to do is to write out something as is follows, but this obviously fails:

MERGE (a:EMAIL {label:userA@host.com}) (a)-[:asdfghjkl]

Then later: MERGE (b:EMAIL {label:userB@host.com}) (b)-[:asdfghjkl]

Can I create these relationships with a query after the fact?

  • 写回答

1条回答 默认 最新

  • doude1917 2017-02-06 16:39
    关注

    Sounds like you should model JSESSIONID as nodes rather than as relationships, as that will allow you to link the JSESSIONID to multiple email addresses, and you can add a unique constraint on the id for fast lookups.

    MERGE (a:EMAIL {label:userA@host.com}) 
    MERGE (b:EMAIL {label:userB@host.com}) 
    MERGE (jsid:JSESSIONID {id:'asdfghjkl'})
    MERGE (a)-[:jsid]->(jsid)
    MERGE (b)-[:jsid]->(jsid)
    

    Your queries to find all :EMAIL nodes using a specific JSESSION id should be quite fast:

    MATCH (email:EMAIL)-[:jsid]->(jsid:JSESSIONID {id:'asdfghjkl'})
    RETURN email
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在不同的执行界面调用同一个页面
  • ¥20 基于51单片机的数字频率计
  • ¥50 M3T长焦相机如何标定以及正射影像拼接问题
  • ¥15 keepalived的虚拟VIP地址 ping -s 发包测试,只能通过1472字节以下的数据包(相关搜索:静态路由)
  • ¥20 关于#stm32#的问题:STM32串口发送问题,偶校验(even),发送5A 41 FB 20.烧录程序后发现串口助手读到的是5A 41 7B A0
  • ¥15 C++map释放不掉
  • ¥15 Mabatis查询数据
  • ¥15 想知道lingo目标函数中求和公式上标是变量情况如何求解
  • ¥15 关于E22-400T22S的LORA模块的通信问题
  • ¥15 求用二阶有源低通滤波将3khz方波转为正弦波的电路