查询说:命中20个结果,实际结果是10个文件/结果

时间:2019-04-18 15:22:53

标签: elasticsearch elasticsearch-aggregation

我需要使用Elasticsearch查询汇总结果,但是结果是错误的。

我尝试了各种写上述查询的方法,但是实际的文档结果很好。但是汇总的结果似乎并不能说明我的查询。

GET mylovely_books/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "geo_shape": {
            "contour": {
              "indexed_shape": {
                "id": "8",
                "type": "my_polygons_1",
                "index": "my_polygons_1",
                "path": "polygon"
              }
            }
          }
        }
      ],
      "must": [
        {
          "range": {
            "year": {
              "gte": 2014,
              "lte": 2019
            }
          }
        }
      ],
      "minimum_should_match": 1
    }

  },
  "aggs": {
    "book_collection" : {
      "terms": {
        "field": "book_type"
      }
    }
  }
}

结果:

{
  "took": 6,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": *19*,
    "max_score": 2,
    "hits": [

... the results actually matching the query.


]


"aggregations": {
    "book_collection": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "Adventure",
          "doc_count": 17
        },
        {
          "key": "Romance",
          "doc_count": 1
        },
        {
          "key": "Mystery",
          "doc_count": 1
        }
      ]
    }
  }

我希望聚合为查询保留费用。预期结果将是10,而不是现在的20(汇总)

0 个答案:

没有答案