2
votes

I'm using OrientDB 2.1.11 and rexster 2.6 and gremlin is the main query language. I use via rexpro (and rexster REST). My issue is: how to get the indexes to hit from gremlin (I must use gremlin not orient sql).

I have a vertex class zipcode, which has 1 property zip_code defined in schema and indexed as dictionary:

zipcode.zip_code    DICTIONARY  ["zip_code"]    SBTREE 

But when I query it using gremlin, its slow when records are around >25k (haven't tested with lower numbers). To give proper context, I try to find the zipcode first, if it doesn't exist then I create the vertex for later use. Find query goes like this:

g.V('@class', 'zipcode').has('zip_code','10018')

Question: Is g.V('@class'... hitting indexes? Is it not going over 1000000 objects of V? Is there a way to write it better to be more efficient for my vertex class i.e. zipcode? I just need to match a property of vertices in my class (zipcode).

Is it better to use has('zip_code', '12345') or filter {it.zip_code == '12345'}? Which one would hit the index created?

What if I have to match more than 1 properties to match against:

.has('zip_code', '12345').has('state','NY').has('city','NEW YORK') 

would has' hit indexes or 'filter{}'? please advise.

1
I even used the studio, same slowness observed when zipcode vertex has 8000 records only and zip_code is dictionary indexed: g.V('@class', 'zipcode').has('zip_code','10018') Query executed in 1.936 sec. Returned 1 record(s). Limit: 20Omair Jafri
some more info, when i use orient sql in studio, it seems to be hitting index: select * from zipcode where zip_code='10018' Query executed in 0.047 sec. Returned 1 record(s). Limit: 20 ' please help how can I hit indexes using gremlinOmair Jafri

1 Answers

0
votes

Ok, after some hit and trial, I was able to figure this out to work via rexster/gremlin. I changed my query to something like:

new GremlinPipeline(g.getVertices('city_state.city','PALMETTO')).has('state_code','FL')

or
g.getVertices('city_state.city','PALMETTO')._().has('state_code','FL')

The g.getVertices method does accept 'class.field' notation (which is required to hit indexes) but it returns an iterator not a pipe so I have to put it in GremlinPipeline, or the alternate _(), in order to write further steps in gremlin.

Hopefully, this would help other folks as well. Made me burn 2 days, its hard when you are really trying to go for a new product coming from neo4j (which has mastered its queries and support).