我试图写一个MQL查询过滤出空值。

查询我现在有(可使用 MQL查询编辑器被执行):

[
  {
    "/common/topic/image" : [
      {
        "id" : null
      }
    ],
    "article" : [
      {
        "content" : null
      }
    ],
    "name" : "bill gates",
    "type" : "/common/topic"
  }
]

我正的结果:

[
  {
    "/common/topic/image" : [
      {
        "id" : "/guid/9202a8c04000641f8000000004fb4c01"
      },
      {
        "id" : "/wikipedia/images/commons_id/4486276"
      }
    ],
    "article" : [
      {
        "content" : null
      },
      {
        "content" : "/guid/9202a8c04000641f800000000903535d"
      }
    ],
    "name" : "Bill Gates",
    "type" : "/common/topic"
  }
]

我试图找出我怎么能过滤掉“内容”:空匹配在查询时的“物品”阵列英寸我通过MQL文档看了,但我没有看到一个明确的方法来做到这一点。

有帮助吗?

解决方案

要过滤掉那些没有分配给他们任何内容的文章,你就必须扩大内容id属性和可选的指令设置为false。

[
  {
    "/common/topic/image" : [
      {
        "id" : null
      }
    ],
    "article" : [
      {
        "content" : {
          "id" : null,
          "optional" : false
        }
      }
    ],
    "name" : "bill gates",
    "type" : "/common/topic"
  }
]

这会给你以下结果:

[
  {
    "/common/topic/image" : [
      {
        "id" : "/guid/9202a8c04000641f8000000004fb4c01"
      },
      {
        "id" : "/wikipedia/images/commons_id/4486276"
      }
    ],
    "article" : [
      {
        "content" : {
          "id" : "/guid/9202a8c04000641f800000000903535d"
        }
      }
    ],
    "name" : "Bill Gates",
    "type" : "/common/topic"
  }
]

有关使用可选的指令的详细信息请参阅文档此处

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top