janusgraph
janusgraph copied to clipboard
When a global property is used and the index is global, and the property has its own unique index in each label, the query is abnormal.
this is a demo about schema.
m = graph.openManagement()
v1 = m.makeVertexLabel('v1').make()
v2 = m.makeVertexLabel('v2').make()
v3 = m.makeVertexLabel('v3').make()
cp0 = m.makePropertyKey('cp0').dataType(String.class).make()
cp1 = m.makePropertyKey('cp1').dataType(String.class).make()
cp2 = m.makePropertyKey('cp2').dataType(String.class).make()
cp0_c = m.buildIndex('cp0_c', Vertex.class).addKey(cp0).buildCompositeIndex()
cp1_c = m.buildIndex('cp1_c', Vertex.class).addKey(cp1).unique().buildCompositeIndex()
cp2_c = m.buildIndex('cp2_c', Vertex.class).addKey(cp2).buildCompositeIndex()
cp2_c_v3 = m.buildIndex('cp2_c_v3', Vertex.class).addKey(cp2).indexOnly(v3).unique().buildCompositeIndex()
m.setConsistency(cp0, ConsistencyModifier.LOCK)
m.setConsistency(cp1, ConsistencyModifier.LOCK)
m.setConsistency(cp2, ConsistencyModifier.LOCK)
m.setConsistency(cp0_c, ConsistencyModifier.LOCK)
m.setConsistency(cp1_c, ConsistencyModifier.LOCK)
m.setConsistency(cp2_c, ConsistencyModifier.LOCK)
m.setConsistency(cp2_c_v3, ConsistencyModifier.LOCK)
m.commit()
------------------------------------------------------------------------------------------------
Vertex Label Name | Partitioned | Static |
---------------------------------------------------------------------------------------------------
v3 | false | false |
v1 | false | false |
v2 | false | false |
---------------------------------------------------------------------------------------------------
Edge Label Name | Directed | Unidirected | Multiplicity |
---------------------------------------------------------------------------------------------------
v1_rt1_v2 | true | false | MULTI |
v2_rt1_v3 | true | false | MULTI |
---------------------------------------------------------------------------------------------------
Property Key Name | Cardinality | Data Type |
---------------------------------------------------------------------------------------------------
cp0 | SINGLE | class java.lang.String |
cp1 | SINGLE | class java.lang.String |
cp2 | SINGLE | class java.lang.String |
---------------------------------------------------------------------------------------------------
Graph Index (Vertex) | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
cp0_c | Composite | false | internalindex | cp0: ENABLED |
cp2_c | Composite | false | internalindex | cp2: ENABLED |
cp1_c | Composite | true | internalindex | cp1: ENABLED |
cp2_c_v3 | Composite | true | internalindex | cp2: ENABLED |
---------------------------------------------------------------------------------------------------
Graph Index (Edge) | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Relation Index (VCI) | Type | Direction | Sort Key | Order | Status |
---------------------------------------------------------------------------------------------------
This is data and gremlin query
gremlin> g.V().elementMap()
==>{cp0=v1, cp1=2, cp2=cp2, id=81924096, label=v1}
==>{cp0=v2, cp1=6, cp2=cp2, id=81928192, label=v2}
==>{cp0=v2, cp1=4, cp2=cp2, id=12440, label=v2}
==>{cp0=v3, cp1=9, cp2=v3_cp2_3, id=16536, label=v3}
==>{cp0=v3, cp1=8, cp2=v3_cp2_2, id=40972488, label=v3}
==>{cp0=v1, cp1=1, cp2=cp2, id=40964304, label=v1}
==>{cp0=v1, cp1=3, cp2=cp2, id=12504, label=v1}
==>{cp0=v3, cp1=7, cp2=v3_cp2_1, id=16600, label=v3}
==>{cp0=v2, cp1=5, cp2=cp2, id=40964328, label=v2}
gremlin> g.E().elementMap()
==>{id=2pkjcw-1crx1c-8v85-1cs074, label=v1_rt1_v2, IN={id=81928192, label=v2}, OUT={id=81924096, label=v1}}
gremlin> g.V().has('cp1','2').out('v1_rt1_v2').has('cp2','cp2').elementMap()
gremlin> g.V().has('cp1','2').out('v1_rt1_v2').elementMap()
==>{cp0=v2, cp1=6, cp2=cp2, id=81928192, label=v2}
gremlin> g.V().has('cp1','2').out('v1_rt1_v2').has('cp2','cp2').explain()
==>Traversal Explanation
============================================================================================================================================================================================================
Original Traversal [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
ConnectiveStrategy [D] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
IdentityRemovalStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
MatchPredicateStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
FilterRankingStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
ByModulatorOptimizationStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
InlineFilterStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
IncidentToAdjacentStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
RepeatUnrollStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
PathRetractionStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
AdjacentToIncidentStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
CountStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
EarlyLimitStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
LazyBarrierStrategy [O] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
AdjacentVertexHasIdOptimizerStrategy [P] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
AdjacentVertexIsOptimizerStrategy [P] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],vertex), HasStep([cp2.eq(cp2)])]
AdjacentVertexHasUniquePropertyOptimizerStrategy [P] [GraphStep(vertex,[]), HasStep([cp1.eq(2)]), VertexStep(OUT,[v1_rt1_v2],edge), HasStep([~adjacent.eq(40964304)]), EdgeVertexStep(IN)]
The problem is ~adjacent.eq(40964304), it will be returned a random vertex when has step matched
- Version: 1.0.0
- Storage Backend: hbase
- Mixed Index Backend: elasticsearch
- Expected Behavior: Each label has its own unique configuration in effect
- Current Behavior: gremlin will return random result when has("") step matched in global index
The same problem as I met. Need a solution.