我正在尝试编写一个过滤掉空值的MQL查询.
我现在的查询(可以使用MQL查询编辑器执行):
[
{
"/common/topic/image" : [
{
"id" : null
}
],
"article" : [
{
"content" : null
}
],
"name" : "bill gates",
"type" : "/common/topic"
}
]
Run Code Online (Sandbox Code Playgroud)
我得到的结果:
[
{
"/common/topic/image" : [
{
"id" : "/guid/9202a8c04000641f8000000004fb4c01"
},
{
"id" : "/wikipedia/images/commons_id/4486276"
}
],
"article" : [
{
"content" : null
},
{
"content" : "/guid/9202a8c04000641f800000000903535d"
}
],
"name" : "Bill Gates",
"type" : "/common/topic"
}
]
Run Code Online (Sandbox Code Playgroud)
我试图弄清楚如何在查询时过滤掉"article"数组中的"content":null匹配.我查看了MQL文档但我没有看到明确的方法来执行此操作.
Sha*_*ter 10
要过滤掉没有分配任何内容的文章,您必须展开content id属性并将optional指令设置为false.
[
{
"/common/topic/image" : [
{
"id" : null
}
],
"article" : [
{
"content" : {
"id" : null,
"optional" : false
}
}
],
"name" : "bill gates",
"type" : "/common/topic"
}
]
Run Code Online (Sandbox Code Playgroud)
这将给您以下结果:
[
{
"/common/topic/image" : [
{
"id" : "/guid/9202a8c04000641f8000000004fb4c01"
},
{
"id" : "/wikipedia/images/commons_id/4486276"
}
],
"article" : [
{
"content" : {
"id" : "/guid/9202a8c04000641f800000000903535d"
}
}
],
"name" : "Bill Gates",
"type" : "/common/topic"
}
]
Run Code Online (Sandbox Code Playgroud)
有关使用可选指令的更多信息,请参阅此处的文档.