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 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的