查询中的elasticsearch索引

时间:2014-05-05 15:50:40

标签: elasticsearch querydsl

我是弹性搜索的新手。并且无法找出如何对索引和类型做出正确的请求 在JSON请求中? (所以我不想在URL中使用索引和类型,如localhost:9200 / myindex / mytype / _search,但要向localhost发出JSON请求:9200 / _search)

我试过这样的事情。但我得到了'aaa'指数而不是'bbb'指数的结果。如何仅从bbb索引获得结果或根本没有结果?

{
  "query": {
    "indices": {
      "indices": [
        "bbb"
      ],
      "query": {
        "bool": {
          "must": [
            {
              "range": {
                "apps.vol": {
                  "lte": 1
                }
              }
            },
            {
              "term": {
                "apps.status": 2
              }
            }
          ],
          "must_not": [],
          "should": []
        }
      }

    }
  }
  ,"size":2,"sort":[],"facets":{}
}

1 个答案:

答案 0 :(得分:2)

根据http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-indices-query.html,默认的no_match_query是" all"。您需要将"no_match_query" : "none"添加到"查询":

的同一级别