A node with record class is stored with a unique record_id. The class definition for a record is this:
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)
The following code is run to lookup nodes using rec_id as the key.
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
At 6153713, two records are retrieved by lookup, including that for rec_id=6153714 while the gremlin query returns a single result. This is the result of the code execution.
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>]
What could be the cause of this error?