首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在gremlin查询的has步骤中测试布尔属性值?

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

Stack Overflow用户
提问于 2019-04-23 04:29:51
回答 1查看 834关注 0票数 0

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

我试过了:

代码语言:javascript
复制
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))

再加上更多的变体,没有一个返回正确的结果

我希望获得Patient顶点中具有alcohol_abuse属性的顶点。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2019-04-23 04:48:52

这很奇怪--这是:

代码语言:javascript
复制
g.V().hasLabel('Patient').has('alcohol_abuse', true)

或者更简洁地说,这是:

代码语言:javascript
复制
g.V().has('Patient', 'alcohol_abuse', true)

应该行得通。我用TinkerGraph做了一个快速测试:

代码语言:javascript
复制
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

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55800717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档