Composite Indexing not working as expected for property on vertex in janusgraph 0.6.1


Nikita Pande
 

g.V().has("newid", "xyz").count().profile()

04:31:35 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [(newid xyz)].

Even though the 
newid is indexed and enabled.

Graph Index (Vertex)           | Type        | Unique    | Backing        | Key:           Status |

---------------------------------------------------------------------------------------------------

newid1                       | Composite   | false     | internalindex  | newid:    REGISTERED |

newid2                   | Composite   | false     | internalindex  | newid:       ENABLED |


Nikita Pande
 
Edited

gremlin> g.V().has("newid","xyz").valueMap(true).tryNext().isPresent()

==>false

gremlin> g.V().has("newid",unfold().is("hash data")).valueMap(true).tryNext().isPresent()

07:01:35 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

==>true
So here thing is when using unfold() index is not being used


hadoopmarc@...
 

H Nikita,

Two questions:
  1. Do I understand right that g.V().has("newid", "xyz").count().profile() gives and index warning while g.V().has("newid","xyz").valueMap(true).tryNext().isPresent() does not give a warning?
  2. What do you want to achieve with .has("newid",unfold().is("0xA017779DFACFC5C6FBA557F7924137F53547326F")) ? I cannot think of anything meaningful for the unfold() step.

Best wishes,    Marc


Nikita Pande
 
Edited

hi @hadoopmarc So the problem is :

"gremlin> g.V().has("newid","xyz").valueMap(true).tryNext().isPresent()"however it gives false.
- This one would have given true response . Also it does use index which I got to know from profile

gremlin> g.V().has("newid",unfold().is("hash data")).valueMap(true).tryNext().isPresent()

07:01:35 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

- This one is able to match value and filter the vertex, however its not using index. 

I want to understand why in case1 its unable to find vertex and why in second case index is not getting used.


hadoopmarc@...
 

Hi Nikita,

Indeed, the janusgraph query optimizer can not handle the has("newid",unfold().is("hash data")) construct in the right way and the index does not trigger. But then, this construct is not necessary. Even if the "newid" property has a LIST cardinality, you can still do:
g.V().has("newid", "hash data").valueMap(true).tryNext().isPresent() and have the index on newid triggered.

Indeed, your example gremlin> g.V().has("newid","xyz").valueMap(true).tryNext().isPresent() should result in true. I checked it on a fresh database and it does. So, please check the steps you took to get your result.

gremlin> testval = m.makePropertyKey('testval').dataType(String.class).cardinality(Cardinality.LIST).make()
==>testval
gremlin> m.buildIndex('byTestVal', Vertex.class).addKey(testval).buildCompositeIndex()
==>byTestVal
gremlin> m.commit()

gremlin> g.addV().property('testval', 'xyz1')
==>v[8192]
gremlin> g.V(8192).property('testval', 'xyz2')
==>v[8192]
gremlin> g.V(8192).values('testval')
==>xyz1
==>xyz2
gremlin> g.V().has("testval","xyz1").valueMap(true).tryNext().isPresent()
==>true

Best wishes,   Marc


Nikita Pande
 

Hi hadoopmarc,

Thanks for elaborate explanation. 
The cardinality is SINGLE for the property "newid".

newid                         | SINGLE      | class java.lang.String  


Can the indexing work with property of single cardinality?

Thanks and Regards,
Nikita


hadoopmarc@...
 

> Can the indexing work with property of single cardinality?

Yes.


Nikita Pande
 

Hi,

There is one observation that, 

1. I faced above issue when the data was loaded with graph.addVertex() method

2. I added sample data using graph traverser g.addV().property().property() and it worked fine. 

I want to understand why is step 1 not giving any response for query g.V().has("newid","xyz") whereas it works with step 2.




hadoopmarc@...
 

Hi Nikita,

Can you please provide me with the complete steps to reproduce your issue? Preferably code lines that work in the Gremlin Console for the JanusGraph inmemory graph, including the schema and indices and the vertex add steps? From your description up till now it is just not possible to make sense of what is happening.

Best wishes,    Marc