# Aggregation search use highlevel client get incorrect result occasional

**URL:** <https://discuss.elastic.co/t/aggregation-search-use-highlevel-client-get-incorrect-result-occasional/263554>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [February 8, 2021, 7:24am UTC](https://discuss.elastic.co/t/aggregation-search-use-highlevel-client-get-incorrect-result-occasional/263554 "2021-02-08T07:24:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZorroYue](https://avatars.discourse-cdn.com/v4/letter/z/74df32/32.png) [@ZorroYue](https://discuss.elastic.co/u/ZorroYue)\
**Post date:** [February 8, 2021, 7:24am UTC](https://discuss.elastic.co/t/aggregation-search-use-highlevel-client-get-incorrect-result-occasional/263554/1 "2021-02-08T07:24:22Z")

</div>

i execute aggregation search use highlevel client，and print searchbuilder as follow:

```auto
{ "size": 0,
  "query": {},
  "aggregations": {
    "term0": {
      "filter": {
        "match_all": {
          "boost": 1
        }
      },
      "aggregations": {
        "countCOUNT_DISTINCTdid": {
          "cardinality": {
            "field": "did",
            "precision_threshold": 40000
          }
        }
      }
    }
  }}

```

but get response content:

```auto
{
  "took": 1002,
  "timed_out": false,
  "terminated_early": false,
  "num_reduce_phases": 0,
  "_shards": {
    "total": 20,
    "successful": 0,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 0,
      "relation": "gte"
    },
    "max_score": null,
    "hits": []
  }
}

```

and search using kinbana get correct result:

```auto
{
  "took" : 231,
  "timed_out" : false,
  "_shards" : {
    "total" : 20,
    "successful" : 20,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : null,
    "hits" : []
  },
  "aggregations" : {
    "term0" : {
      "doc_count" : 8526098,
      "countCOUNT_DISTINCTdid" : {
        "value" : 3929368
      }
    }
  }
}

```

and it's occasional,other search is ok at the same time

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 8, 2021, 7:24am UTC](https://discuss.elastic.co/t/aggregation-search-use-highlevel-client-get-incorrect-result-occasional/263554/2 "2021-03-08T07:24:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
