如何在Titan Gremlin查询中使用ElasticSearch索引? [英] How to use ElasticSearch index in Titan Gremlin query?

查看:192
本文介绍了如何在Titan Gremlin查询中使用ElasticSearch索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于

I've managed to set up Titan (v0.3.1) with Elastic Search in embedded mode, thanks to the Titan docs. However, my question is now: how do I take advantage of the ES indexing?

例如,我想使用Text.CONTAINS(根据上面链接的文档支持).具体来说,我想检索名称为my_label的键的值中包含字符串"abc"的节点.

For example, I would like to use Text.CONTAINS (which is supported, according to docs linked above). Specifically, I'd like to retrieve nodes with the string "abc" somewhere in the value for a key called my_label.

通过Gremlin控制台,什么语法可以实现此目标?

What syntax would achieve this goal from the Gremlin console?

推荐答案

搜索外部索引

以下查询将使用Elasticsearch后端:

Searching against an external index

The following query will use the Elasticsearch backend:

g.query().has('my_label',CONTAINS,'abc').edges()

通常,任何包含三个参数的has查询都将使用您的外部索引后端(Elasticsearch或Lucene).

In general, any has query that contains three arguments will use your external index backend (Elasticsearch or Lucene).

以下查询将改为执行完全匹配:

The following query would perform an exact match instead:

g.query().has('my_label','abc').edges()

graph.makeType().name("my_label").dataType(String.class).indexed("elastic", Vertex.class).unique(Direction.OUT).makePropertyKey();

添加Titan原生索引和外部索引之间的主要区别是indexed(..)调用中的第二个参数,该参数指示应在其中索引属性的外部索引的名称.

The key difference between adding a Titan native index and an external index is the second parameter in the indexed(..) call which indicates the name of the external index in which your property should be indexed.

不幸的是,现在,一旦具有某个键的属性存在,就无法在该键上添加索引.您将不得不重新绘制图表.

Unfortunately right now, once a property exists with a certain key, you cannot add an index on that key; you would have to start with a fresh graph.

Titan文档非常容易阅读: https://github.com/thinkaurelius/titan/wiki/Indexing-Backend-概述

The Titan docs are pretty easy to read: https://github.com/thinkaurelius/titan/wiki/Indexing-Backend-Overview

(奖励: Titan正在进行扩展,以包括其他类型的部分搜索,包括前缀和正则表达式: https://github.com/thinkaurelius/titan/pull/311 )

(Bonus: Titan is being expanded to include other types of partial searching including prefix and regexp: https://github.com/thinkaurelius/titan/pull/311)

这篇关于如何在Titan Gremlin查询中使用ElasticSearch索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆