Gremlin不区分大小写的搜索 [英] Gremlin case insensitive search

查看:88
本文介绍了Gremlin不区分大小写的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Gremlin的新手,我正在使用Gremlin控制台从图形数据库中读取数据.在图形中,存在带有标签设备"的顶点.这些顶点具有与之关联的属性名称".我需要找出是否有一个具有特定名称的顶点.此检查必须不区分大小写.

I am new to Gremlin and I am using the Gremlin console to read data from a graph database. In the graph, there are vertices with label "Device". These vertices have a property "name" associated with them. I need to find out if there is a vertex that has a certain name. This check has to be case insensitive.

假设我要在关系数据库中执行此操作,我可以编写以下查询:

Suppose I was to do this in a relational database, I could write the following query:

SELECT * FROM device d WHERE LOWER(d.name) = 'mydevice'

我正在寻找与Gremlin中的'LOWER'类似的功能.如果没有该功能,有人可以告诉我如何在不考虑字母大小写的情况下搜索顶点的属性吗?

I am searching for a function similar to 'LOWER' in Gremlin. If there isn't a function for that, can somebody tell me how I can search properties of vertices without considering alphabetic case?

谢谢.

推荐答案

正式地,Gremlin当前只有三个文本

Officially, Gremlin currently only has three text predicates at this time as exposed by TextP: startingWith, endingWith and containing (as well as their negations), but their default implementations are case sensitive:

gremlin> g.V().has('person','name',containing('ark')).values('name')
==>marko
gremlin> g.V().has('person','name',containing('Ark')).values('name')
gremlin> 

根据您使用的启用了TinkerPop的图形数据库,您可能会具有这种功能以及其他更高级的搜索选项(例如regex).例如,JanusGraph支持全文搜索(不区分大小写)以及许多其他选项.DS Graph还具有富文本搜索系统位于基本的Gremlin选项之上.因此,如果您对描述的搜索类型有明确的需求,则可能需要研究各个图形系统提供的选项.

Depending on the TinkerPop-enabled graph database that you use, you may have this sort of feature available to you as well as other more advanced search options (e.g. regex). For example, JanusGraph supports full-text search as case insensitive as well as a host of other options. DS Graph also has a rich text search system on top of the basic Gremlin options. So, if you have a explicit need for the type of search you describe you may need to look into the options provided by individual graph systems.

虽然出于多种原因不建议您使用lambda:

While it's not recommended for a number of reasons you can use a lambda:

gremlin> g.V().filter{it.get().value('name').toUpperCase() == 'MARKO'}.values('name')
==>marko

lambda的缺点是:

The downside to lambdas are that:

  1. 并非所有提供商都支持它们,因此降低了代码的可移植性
  2. 与严格使用Gremlin步骤进行遍历相比,他们要求的部队评估成本可能更高.

TinkerPop正在缓慢地识别不同供应商提供的搜索选项之间的共性,并将在机会出现时继续推广这些功能,以便可以作为Gremlin语言本身的一等公民使用.

TinkerPop is slowly identifying commonalities among search options provided by different vendors and will continue to generalize those features as opportunity presents itself, so that they are available as first-class citizens in the Gremlin language itself.

这篇关于Gremlin不区分大小写的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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