如何在gremlin查询的has步骤中测试布尔属性的值?

如何在gremlin查询的has步骤中测试布尔属性的值?,gremlin,traversal,janusgraph,Gremlin,Traversal,Janusgraph,我用模式定义了一个顶点,该顶点的一些属性是布尔类型的。我现在尝试查询顶点,并根据这些属性的布尔值过滤结果 我试过: g.V().hasLabel('Patient').has('alcohol_abuse', eq(true)) g.V().hasLabel('Patient').has('alcohol_abuse', true) g.V().hasLabel('Patient').has('alcohol_abuse', constant(true)) g.V().hasLabel('Pat

我用模式定义了一个顶点,该顶点的一些属性是布尔类型的。我现在尝试查询顶点,并根据这些属性的布尔值过滤结果

我试过:

g.V().hasLabel('Patient').has('alcohol_abuse', eq(true))
g.V().hasLabel('Patient').has('alcohol_abuse', true)
g.V().hasLabel('Patient').has('alcohol_abuse', constant(true))
g.V().hasLabel('Patient').has('alcohol_abuse', eq(1))
再加上更多的变化,没有一个返回正确的结果

我希望得到患者顶点中属性为true的顶点

谢谢

真奇怪-这是:

g.V().hasLabel('Patient').has('alcohol_abuse', true)
或者更简洁地说,这是:

g.V().has('Patient', 'alcohol_abuse', true)
应该有用。我用TinkerGraph做了一个快速测试:

gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV('Patient').property('alcohol_abuse',true).
......1>   addV('Patient').property('alcohol_abuse',false).iterate()
gremlin> g.V().has('Patient','alcohol_abuse',true).count()
==>1
gremlin> g.V().has('Patient','alcohol_abuse',false).count()
==>1
因此,这绝对是所有TinkerPop实现(包括JanusGraph)的预期结果。如果您没有看到问题的解决方案,您可能希望发布您的Gremlin控制台会话的文本以进行演示。

这很奇怪-这是:

g.V().hasLabel('Patient').has('alcohol_abuse', true)
或者更简洁地说,这是:

g.V().has('Patient', 'alcohol_abuse', true)
应该有用。我用TinkerGraph做了一个快速测试:

gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV('Patient').property('alcohol_abuse',true).
......1>   addV('Patient').property('alcohol_abuse',false).iterate()
gremlin> g.V().has('Patient','alcohol_abuse',true).count()
==>1
gremlin> g.V().has('Patient','alcohol_abuse',false).count()
==>1

因此,这绝对是所有TinkerPop实现(包括JanusGraph)的预期结果。如果您没有看到问题的解决方案,您可能希望发布您的Gremlin控制台会话的文本以进行演示。

谢谢!在查看您的帖子并查看我加载的数据后,我确定我没有在graph属性中正确加载真值。我正在通过CSV文件加载此数据,但没有正确计算“True”的文本值。我已经重新加载了数据,查询正在按照您的描述进行。再次感谢汉克斯!在查看您的帖子并查看我加载的数据后,我确定我没有在graph属性中正确加载真值。我正在通过CSV文件加载此数据,但没有正确计算“True”的文本值。我已经重新加载了数据,查询正在按照您的描述进行。再次感谢