MarkLogic-具有提取文档数据的查询选项 [英] MarkLogic - Query Options with extract-document-data
问题描述
MarkLogic 9.0-6.2版
MarkLogic version 9.0-6.2
我正在尝试使用Query选项中的extract-document-data提取信封的一部分(如下所示).
I am trying to extract a portion of the envelope (example given below) using extract-document-data in Query options.
{
"envelope": {
"headers": {
"audit": {
"created-by": "admin",
"last-updated-by": "*******"
}
},
"instance": {
"UserId": "Test1",
"UserName":"TestName"
"Phones":[
{
"PhoneType":"Home",
"PhoneNum":"18009897800"
},
{
"PhoneType":"Cell",
"PhoneNum":"1239897800"
}
]
}
}
}
我的要求只是返回UserId和UserName.所以我在选项文件中尝试了以下代码.
My requirement is just to return UserId and UserName. So I tried below code in Options file.
"extract-document-data":
{
"selected": "exclude",
"extract-path": [ "/envelope/instance/Phones" ]
},
"extract-document-data":
{
"selected": "include",
"extract-path": [ "/envelope/instance" ]
}
我收到如下响应
{
"instance": {
"UserId": "Test1",
"UserName":"TestName"
"Phones":[
{
"PhoneType":"Home",
"PhoneNum":"18009897800"
},
{
"PhoneType":"Cell",
"PhoneNum":"123989780"
}
]
}
}
此代码不排除电话"属性.另外,在输出中返回"instance"属性,但我只需要UserId和UserName.
This code is not excluding the "Phones" property. Also, returning "instance" property in the output, but I just need the UserId and UserName.
如何编码排除和包含在同一选项文件中?另外,在包含路径中,如何仅指定要返回的后代(在我的情况下,是"instance"属性的后代.
How can I code both exclude and include in the same options file? Also, in the include path, how do I specify just the descendants to be returned (in my case, descendants of "instance" property.
提前谢谢!
推荐答案
响应是否以类似于以下内容的规范提取正确的数据?
Does the response extract the right data with a specification similar to the following?
"extract-document-data": {
"selected": "include",
"extract-path": [
"/envelope/instance/(UserId|UserName)"
]
}
希望有帮助,
这篇关于MarkLogic-具有提取文档数据的查询选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!