OrientDB Gremlin - Retrieve Vertex for a class in gremlin not hitting indexes

妖精的绣舞 提交于 2019-12-22 17:54:21

问题


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:


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).



来源:https://stackoverflow.com/questions/35447890/orientdb-gremlin-retrieve-vertex-for-a-class-in-gremlin-not-hitting-indexes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!