我有一个包含单词和与这些单词相关的文档的数据集。我想在它们上设置标签以将它们分为这两个类别。我可以通过这样做来创建标签:
if not "Social Words" in graph_db.node_labels:
neo4j.Schema.create_index(graph_db.schema, "Social Words", "word")
if not "Documents" in graph_db.node_labels:
neo4j.Schema.create_index(graph_db.schema, "Documents", "url")
问题是我需要在“word”和“url”字段上强制执行唯一性。我正在添加节点和标签,如下所示
doc,= graph_db.create({"url": url})
doc.add_labels("Documents")
我的问题是:
- 有没有办法通过使用 get_or_create 将节点添加到标签索引
- py2neo api 是否有办法在标签索引上强制执行唯一性
- 有没有更好的方法来完成这一切。文档有点模糊