json - Elasticsearch 术语过滤器引发 "filter does not support [mediatest]"

标签 json elasticsearch dsl

我的查询是这样的:

{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "online": 1
              }
            },
            {
              "terms": {
                "mediaType": "flash"
              }
            }
          ]
        }
      }
    }
  }
}

它引发 QueryParsingException [[comos_v2] [terms] 过滤器不支持 [mediaType]],其中“mediaType”字段在映射中完全不存在. 我的问题是为什么术语过滤器不会引发异常?

最佳答案

以上不是有效的查询 DSL。在上面Terms filter “mediaType”字段的值应该是一个数组

应该是这样的:

{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "online": 1
              }
            },
            {
              "terms": {
                "mediaType": ["flash"]
              }
            }
          ]
        }
      }
    }
  }
}

关于json - Elasticsearch 术语过滤器引发 "filter does not support [mediatest]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30363647/

相关文章:

java - 将 JSON 数组发布到 Spring Boot RestController 中

java - 如何使用带有 Gson 的 retrofit2 将空字符串视为 null

Groovy 1.8 a b c 风格

c# - 突出显示所有字段 Nest ElasticSearch

c# - 在 C# 中编写我的第一个 DSL 并挂断了 func<T> & Action

ruby - 适当的 DSL 语法

javascript - 将从 JSON 解析的对象绑定(bind)到类

python - JSON 网站响应到 Python 字典

elasticsearch - 在 Elasticsearch 中无法更改 “maxClauseCount”值

c# - 查询文档并过滤嵌套字符串列表(即标签)中的特定值