【问题标题】:cloudant nosql db query with regex使用正则表达式的 cloudant nosql db 查询
【发布时间】:2018-02-09 00:38:10
【问题描述】:

我有一个 cloudant nosql 数据库,其中有一些记录如下:

{
 "role": "utente",
 "nome": "Rocco",
 "cognome": "Di Vitto",
 "team": "sap pm-cs",
 "company": "wrestling",
 "appManager": "john Ford",
 "teamLeader": "Rendy Orton, Colombo M.R."
}

我想使用 $regex the teamLeader 字段查询我的数据库,传递与“Randy Orton”或“Colombo M.R.”匹配的单个字符串但我无法弄清楚匹配两个逗号分隔字符串的正则表达式。我试过阅读 Erlang 查询结构,但没有找到解决方案。一些帮助会非常有用。提前致谢

【问题讨论】:

  • 你的意思是this
  • 在这个问题中没有看到perl
  • 我编写了这个查询 { "selector": { "teamLeader": { "$.+(?|(Colombo M\.R\.)|(Rendy Orton)).+" : " Randy Orton" } } } 但它没有用。

标签: regex cloudant


【解决方案1】:

在提供正则表达式时,您应该使用$regex 运算符。你有没有尝试过这样的事情:

{
   "selector": {
      "teamLeader": {
         "$regex": "(Colombo M.R.)|(Rendy Orton)"
      }
   }
}

【讨论】:

    猜你喜欢
    • 2020-12-24
    • 2021-01-09
    • 1970-01-01
    • 2023-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多