MarkLogic - 基于 JSON 对象的路径搜索(不使用路径范围索引)

MarkLogic - Search based on the path of JSON object (without using path range index)

马克逻辑:9.0-6.2

我们在客户实体中有一个 JSON 文档,如下所示。

"CustomerInfo": {
  "IdInfo": {
     "CustomerId":"12345"
  }, 
  "PartyRltp": {
      "CustomerId":"45678"
  }
}

我的需求是在特定路径下根据CustomerId查找文档CustomerInfo.IdInfo.CustomerId

所以如果我搜索“12345”,应该会返回上面的文件。但是如果我用“45678”搜索,应该不会返回上面的文件。

我创建了路径范围索引并使用了 cts.pathRangeQuery('/CustomerInfo/IdInfo/CustomerId','=', '12345')。然而,意识到路径范围索引非常昂贵,所以寻找一种没有路径范围索引的方法。

提前致谢!

我想你在找 cts.jsonPropertyScopeQuery:

cts.jsonPropertyScopeQuery(
  'IdInfo',
  cts.jsonPropertyValueQuery(
    'CustomerId',
    '12345'
  )
)

HTH!