Bulbflow Neo4j索引查找错误 - 使用唯一键查找多个结果

时间:2014-09-02 10:39:43

标签: python indexing neo4j lookup bulbs

具有记录类的节点存储有唯一的record_id。记录的类定义是:

    class BaseRecord(Node):
     element_type = "baserecord"

     rec_id = Integer(nullable=False,unique=True)
     name = String(nullable=False)

    class Record(BaseRecord):
     element_type = "record"

     rec_type = String(nullable=False)

运行以下代码以使用rec_id作为键来查找节点。

    for i in range(6153713,6153717):
     records = mmidata.graph_db.record.index.lookup("rec_id",i)
     if records != None:
      print "Index Lookup - ",i, list(records)
     else:
      print "Index Lookup - ",i,records
     script = "g.V.filter{it.element_type=="+"\"record\""+"}.filter{it.rec_id=="+str(i)+"}" 
     print "Executing:",script
     records = mmidata.graph_db.gremlin.query(script)
     if records != None:
      print "Gremlin Result - ",i, list(records)
     else:
      print "Gremlin Result - ",i,records

在6153713,通过查找检索两条记录,包括rec_id = 6153714的记录,而gremlin查询返回单个结果。这是代码执行的结果。

Index Lookup -  6153713 [<Record: http://localhost:7474/db/data/node/5684>, <Record: http://localhost:7474/db/data/node/25977>]
Executing: g.V.filter{it.element_type=="record"}.filter{it.rec_id==6153713}
Gremlin Result -  6153713 [<Record: http://localhost:7474/db/data/node/5684>]

Index Lookup -  6153714 [<Record: http://localhost:7474/db/data/node/25977>]
Executing: g.V.filter{it.element_type=="record"}.filter{it.rec_id==6153714}
Gremlin Result -  6153714 [<Record: http://localhost:7474/db/data/node/25977>]

Index Lookup -  6153715 [<Record: http://localhost:7474/db/data/node/25978>]
Executing: g.V.filter{it.element_type=="record"}.filter{it.rec_id==6153715}
Gremlin Result -  6153715 [<Record: http://localhost:7474/db/data/node/25978>]

Index Lookup -  6153716 [<Record: http://localhost:7474/db/data/node/25979>]
Executing: g.V.filter{it.element_type=="record"}.filter{it.rec_id==6153716}
Gremlin Result -  6153716 [<Record: http://localhost:7474/db/data/node/25979>]

导致此错误的原因是什么?

0 个答案:

没有答案