在JanusGraph上搜索多属性 [英] Searching Multiproperties on JanusGraph

查看:65
本文介绍了在JanusGraph上搜索多属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对基数为多的属性有疑问.当我使用具有基数列表或集合的属性时,可以使用BerkleyDB对其进行搜索吗?还是需要索引?还可以在其上执行NotIn和或IN操作吗?例如,如果我的属性包含数据[1,2,3],我可以在[1,2,3]或[4] NotIn [1,2,3]中做一个[2]

I have a question on properties whose cardinality is Multiple. When I use a property which has a Cardinality list or Set, Can I search on it using the BerkleyDB ? Or does it need to be indexed ? Also Can I do a NotIn and or IN Operation on it ? For Example, if my property contains data [1,2,3] can I do a [2] in [1,2,3] or [4] NotIn [1,2,3]

推荐答案

无论选择了哪种存储后端,都可以针对列表/集合属性进行查询.您应该使用索引来提高性能,因为它将需要完全扫描而没有图形索引(您将看到 WARN 消息). without()操作还将需要完整扫描.

You can query against a list/set property regardless of the chosen storage backend. You should use an index for performance because it will require a full scan without a graph index (you will see a WARN message). The without() operation will also require a full scan.

gremlin> [ JanusGraph.version(), Gremlin.version() ]
==>0.2.0
==>3.2.6
gremlin> graph = JanusGraphFactory.build().
......1>     set('storage.backend', 'berkeleyje').
......2>     set('storage.directory', '/tmp/berkeleyje').
......3>     open()
==>standardjanusgraph[berkeleyje:/tmp/berkeleyje]

gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@32b0876c
gremlin> nums = mgmt.makePropertyKey('nums').
......1>     dataType(Integer.class).cardinality(Cardinality.LIST).make()
==>nums
gremlin> numsIdx = mgmt.buildIndex('numsIdx', Vertex.class).
......1>     addKey(nums).buildCompositeIndex()
==>numsIdx
gremlin> mgmt.commit()
==>null

gremlin> g = graph.traversal()
==>graphtraversalsource[standardjanusgraph[berkeleyje:/tmp/berkeleyje], standard]
gremlin> g.addV().
......1>     property(VertexProperty.Cardinality.list, 'nums', 1).
......2>     property(VertexProperty.Cardinality.list, 'nums', 2).
......3>     property(VertexProperty.Cardinality.list, 'nums', 3)
==>v[4136]
gremlin> g.addV().property(VertexProperty.Cardinality.list, 'nums', 4)
==>v[8232]
gremlin> g.V().valueMap(true)
17:53:44 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>[label:vertex,nums:[1,2,3],id:4136]
==>[label:vertex,nums:[4],id:8232]
gremlin> g.V().has('nums', within(2))
==>v[4136]
gremlin> g.V().has('nums', without(4))
17:53:45 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [(nums <> 4)]. For better performance, use indexes
==>v[4136]

这篇关于在JanusGraph上搜索多属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆