【问题标题】:neomodel: how to share index across StructuredNode Objectsneomodel:如何在 StructuredNode 对象之间共享索引
【发布时间】:2013-08-15 09:07:44
【问题描述】:

如何在 neomodel 中跨节点对象共享唯一索引,而不实例化单独的对象以仅保存索引数据? 我想根据索引查询找到对象,例如:

...
mynode = BaseObject.index.get(uid=uid_of_Type1Object)
# mynode is now of type `Type1Object`

class BaseObject(StructuredNode):
    uid = StringProperty(unique_index=True)
    ...

class Type1Object(BaseObject):
    ...
    def assign_uid(self, guid):
        # I may need tweaking of uid generator
        # on subclass level
        self.uid = guid

class Type2Object(BaseObject):
    ...
    def assign_uid(self, guid):
        self.uid = guid

【问题讨论】:

  • "neomodel" 不作为标签存在......也许如果其中一位大人物好心帮忙...... ;)
  • @Nicholas 非常感谢!

标签: python indexing neo4j cypher neomodel


【解决方案1】:

https://github.com/robinedwards/neomodel/commit/1f1b43377b25cd4d41e17ce2b7f9ca1a1643edea 中添加了对 StructuredNode 子类上的自定义索引的支持

class BaseObject(StructuredNode):
    __index__ = 'MyBaseIndex'
    uid = StringProperty(unique_index=True)
    ...

class Type1Object(BaseObject):
    __index__ = 'MyBaseIndex'
    ...
    def assign_uid(self, guid):
        # I may need tweaking of uid generator
        # on subclass level
        self.uid = guid

class Type2Object(BaseObject):
    __index__ = 'MyBaseIndex'
    ...
    def assign_uid(self, guid):
        self.uid = guid

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 2012-08-18
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多