【问题标题】:Marklogic 9 extract-document-data on json documentsMarklogic 9 在 json 文档上提取文档数据
【发布时间】:2020-11-10 11:53:39
【问题描述】:

文档结构如下

 {
    "sNo": 0,
    "id": 31575378,
    "title": "Sustained preventive chemotherapy",
    "journal": "Infectious diseases of poverty",
    "publ_date": "2019-10-03",
    "species": "Human",
    "drug": ["Allegra", "Citrizin"],
    "symptom": ["Cold", "Cough", "Fatigue"]
 }

当我尝试从文档中提取药物 json 属性时

<extract-document-data>
                            <extract-path>/drug</extract-path>                                                                                  
                     </extract-document-data>

我收到类似的回复

<search:extracted kind="array">{"drug":"Dolo"}, {"drug":"Crocin"}, {"drug":"Combiflame",{"symptom":"Fever"} {"symptom":"Body Pain"}{"symptom":"Fatiguue"}]</search:extracted>

而我正在寻找药物作为 json 数组的输出:

<search:extracted kind="array">[{"drug":["Dolo","Crocin","Combiflame"]}]</search:extracted>

【问题讨论】:

    标签: json marklogic


    【解决方案1】:

    是否可以将提取路径指定为:

    /array-node("drug")
    

    将命名的 XPath 步骤应用于 JSON 时,MarkLogic 会跳过数组容器以匹配数组值项。 (类似地,MarkLogic 会跳过对象容器以匹配对象属性。)

    为了匹配容器,XPath 应该提供明确的节点测试,例如 array-node()object-node()

    更多详情,请参见:

    https://docs.marklogic.com/guide/app-dev/json#id_15818

    希望对您有所帮助,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-01
      相关资源
      最近更新 更多