json - 在 MarkLogic 6 中将文档存储为 JSON 的性能优势

标签 json marklogic

如果我要在 2 个单独的文档中存储相同的标记,一个 XML,另一个 JSON,在 MarkLogic 6 中,MarkLogic 会自动将 JSON 等价物转换为 XML,并在这方面对其进行索引,或者两者都存储在它们的各自的格式?

我的意思是,MarkLogic 是否将所有文档存储为 XML,而不管是否在查询时简单地将 JSON 转换应用于 JSON 文档?

如果文档以 native 格式存储,就性能而言,以 JSON 格式存储文档比以 XML 格式存储文档有什么优势吗?

下面是一个示例代码片段:

if($outputFormat="json") then (: result in json format :)       
    let $custom-config :=
        let $config := json:config("custom")
        return (map:put($config, "array-element-names",(xs:QName("lp:lesson_plan"), 
                                                        xs:QName("lp:instructional_segment"),
                                                        xs:QName("lp:strand_type"),                                                             
                                                        xs:QName("lp:resource"),
                                                        xs:QName("lp:level"),
                                                        xs:QName("lp:discipline"),
                                                        xs:QName("lp:language"),
                                                        xs:QName("lp:program"),
                                                        xs:QName("lp:grade"),
                                                        xs:QName("res:strand_type"),
                                                        xs:QName("res:resource"),
                                                        xs:QName("res:ISBN"),
                                                        xs:QName("res:level"),
                                                        xs:QName("res:standard"),
                                                        xs:QName("res:secondaryURL"),
                                                        xs:QName("res:grade"),
                                                        xs:QName("res:keyword"))), 
                map:put($config, "whitespace","ignore"),
                map:put($config, "text-value","value"),
                $config) 
    return json:transform-to-json($finalResult, $custom-config)
else (: finalResult in xml format :)        
    $finalResult

最佳答案

MarkLogic 是 XML 原生的,需要将 JSON 转换为 XML 才能将其存储在数据库中。有一个高级 JSON 库来执行转换。主要函数是 json:transform-to-jsonjson:transform-from-json,正确配置后应该提供无损转换。

我认为与您的示例的主要区别在于您是想使用自己的过程还是使用 MarkLogic 的工具包转换为 XML。

更多详细信息,请参阅 MarkLogic 的文档: http://docs.marklogic.com/guide/app-dev/json

关于json - 在 MarkLogic 6 中将文档存储为 JSON 的性能优势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17659018/

相关文章:

group-by - 如何在 Marklogic 中使用 Group By?

在 for 循环中带有 if 条件的 XQuery

java - CORB 作业 : Handle ServerConnectionException: Connection reset by peer

json - Flutter - 读取 JSON 文件时出错没有这样的文件或目录

json - 在 node.js 的帮助下在服务器上运行 three.js,将模型导出到 json 并通过 ajax 加载到最终用户

json - 如何在 MarkLogic 的 XQuery 中以编程方式创建 JSON?

marklogic - 我什么时候应该使用 MarkLogic 9 的 Optic API?

json - Spray-Json:如何解析Json阵列?

javascript - 我的网页无法通过 JSON 请求运行

java - Elasticsearch错误: failed to parse,文档为空