【问题标题】:Azure Cosmos DB Graph Wildcard searchAzure Cosmos DB Graph 通配符搜索
【发布时间】:2017-12-05 11:04:03
【问题描述】:

是否可以在 Azure Cosmos Graph DB 中使用 contains 搜索 Vertex 属性?

例如,我想查找姓名中包含'Jr' 的所有人?

g.V().hasLabel('person').has('name',within('Jr')).values('name')

似乎within('') 函数只过滤完全等于'Jr' 的值。我正在寻找一个包含。 最好不区分大小写。

【问题讨论】:

  • 通常使用 Tinkerpop / gremlin,您可以执行 g.V().hasLabel('person).filter{it.getProperty('name').toLowerCase().contains('jr')}.values('name') 之类的操作,但 Cosmos DB Graph 尚不支持闭包。一旦闭包可用,将响应此线程。
  • 我在使用 Titan 时使用了 textContains,但它看起来不适用于 Cosmos gV().hasLabel('person').has('name',textContains('Jr'))跨度>

标签: azure-cosmosdb gremlin


【解决方案1】:

目前没有任何文本匹配功能可用于 CosmosDB。但是,我能够通过使用 Javascript match() 函数的 UDF(用户定义函数)来实现通配符搜索功能:

function userDefinedFunction(input, pattern) { return input.match(pattern) !== null; };

然后您必须将查询编写为 SQL 并使用您定义的 UDF(下面的示例假设您调用了函数“REGEX”

SELECT * FROM c where(udf.REGEX(c.name[0]._value, '.*Jr.*') and c.label='person')

性能远非理想,因此您需要根据您的延迟和成本角度来决定该解决方案是否可以接受。

【讨论】:

  • 来自门户的您好,我们可以这样做,但是从 Java SDK 可以做到吗?
【解决方案2】:

Azure 团队现已实现Tinkerpop predicates for String

Azure 团队已在其反馈网站上向a user here“宣布”此消息。

我还没有测试所有这些,但包含适合我的作品(但它区分大小写)

g.V().hasLabel('doc').or(__.has('title', containing('truc')), __.has('tags', containing('truc')))

TextP.startingWith(string)

传入的字符串是否以提供的字符串开头?

TextP.endingWith(字符串)

传入的字符串是否以提供的字符串结尾?

TextP.包含(字符串)

传入的字符串是否包含提供的字符串?

TextP.notStartingWith(string)

传入的字符串不是以提供的字符串开头吗?

TextP.notEndingWith(字符串)

传入的字符串不是以提供的字符串结尾吗?

TextP.notContaining(字符串)

传入的字符串不包含提供的字符串吗?

【讨论】:

    猜你喜欢
    • 2019-08-30
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 2021-08-01
    • 1970-01-01
    相关资源
    最近更新 更多