OrientDB Gremlin-检索gremlin中的类的顶点但未达到索引 [英] OrientDB Gremlin - Retrieve Vertex for a class in gremlin not hitting indexes
问题描述
我正在使用OrientDB 2.1.11和rexster 2.6,并且gremlin是主要的查询语言.我通过rexpro(和rexster REST)使用.我的问题是:如何从gremlin获取索引(我必须使用gremlin而不是sql).
我有一个顶点类邮政编码,其中有1个属性zip_code在架构中定义,并被索引为字典:
zipcode.zip_code DICTIONARY ["zip_code"] SBTREE
但是当我使用gremlin查询它时,当记录大约> 25k时,它会变慢(尚未用较小的数字进行测试).为了提供适当的上下文,我尝试首先查找邮政编码,如果不存在,则创建顶点以供以后使用.查找查询是这样的:
g.V('@class', 'zipcode').has('zip_code','10018')
问题:gV('@ class'...是否命中索引?难道不超过V的1000000个对象吗?有什么办法可以更好地为我的顶点类(例如邮政编码)编写更高效的代码吗?我只需要匹配我的班级(邮政编码)中顶点的属性.
使用has('zip_code', '12345')
或filter {it.zip_code == '12345'}
更好吗?哪一个命中创建的索引?
如果我必须匹配多个属性才能匹配:
.has('zip_code', '12345').has('state','NY').has('city','NEW YORK')
会有命中索引"或过滤器{}"吗?请指教.
好吧,经过一番尝试和尝试,我能够通过rexster/gremlin弄清楚这一点.我将查询更改为:
new GremlinPipeline(g.getVertices('city_state.city','PALMETTO')).has('state_code','FL')
或
g.getVertices('city_state.city','PALMETTO')._().has('state_code','FL')
g.getVertices方法确实接受"class.field"表示法(命中索引是必需的),但是它返回的是迭代器而不是管道,因此我必须将其放入GremlinPipeline或替代的_()中,以便进行排序在gremlin中编写其他步骤.
希望这对其他人也有帮助.让我筋疲力尽了2天,当您真的想购买neo4j的新产品时,这很难.
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.
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).
这篇关于OrientDB Gremlin-检索gremlin中的类的顶点但未达到索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!