Elasticsearch:需要有关id过滤器的帮助

cur*_*us1 4 elasticsearch

我是Elasticsearch的新手.我有一个映射,其中包含以下字段:

{
  "book": {
    "book": {
      "dynamic": "false",
      "_source": {
        "enabled": true
      },
      "_id": {
        "path": "id"
      },
      "properties": {
        "id": {
          "type": "long",
          "store": "yes",
          "index": "not_analyzed",
          "include_in_all": false
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我能够创建索引并添加文档.但是,当我运行查询时,例如:

{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "ids": {
          "type": "long",
          "values" : [10]
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

它什么都不返回(索引有一个id = 10的文档).我对此链接感到困惑:

任何人都可以启发我吗?我做错了什么?

cur*_*us1 7

我明白了.使用id过滤器的正确方法如下:

{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "ids": {
          "type": "book",
          "values" : [10]
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

type参数应该是文档类型,而不是id字段的类型.希望这有助于其他人.