简体   繁体   English

是否可以根据marklogic中json文档中的数组大小查询或排序文档?

[英]Is it possible to query or sort the document based on the size of an array inside the json document in marklogic?

{
  "name": "ruby",
  "phone": [
    {
      "type": "mobile",
      "number": 12345678
    },
    {
      "type": "office",
      "number": 2433242
    }
  ]
}

My problem here is, I just want to sort the documents like the one mentioned above based on the size of phone array.我的问题是,我只想根据电话数组的大小对上面提到的文档进行排序。

You could create a Template Driven Extraction (TDE) with a column that has the size of the phone array, and then search and sort with the Optic API.您可以使用具有电话数组大小的列创建模板驱动提取 (TDE) ,然后使用 Optic API 进行搜索和排序。

Unfortunately, you cannot simply create a path-range-index with the following XPath, because it isn't an indexable XPath expression:不幸的是,您不能简单地使用以下 XPath 创建路径范围索引,因为它不是可索引的 XPath 表达式:

/array-node('phone')/count(node())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM