Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'buckets' does not exist on type 'AggregationsCardinalityAggregate'. #2312

Open
premtemp1 opened this issue Jul 18, 2024 · 1 comment

Comments

@premtemp1
Copy link

premtemp1 commented Jul 18, 2024

Hello,
I have nodejs/typescipt function that I would like to get the aggregations. buckets result. However, I get the error Property 'buckets' does not exist on type 'AggregationsCardinalityAggregate'.

The basic code is console.log(res?.aggregations?.unique_val.buckets) which throws the error. I am able get the object using console.log(res?.aggregations?.unique_val)

can you please let me know why I cannot get any of key/val day within the aggregations?.unique_val object. Here is result json from the search

{
  "took": 7,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 10000,
      "relation": "gte"
    },
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "unique_industries": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "technologies",
          "doc_count": 27965
        },
        {
          "key": "finance & accounting",
          "doc_count": 20727
        },
        {
          "key": "manufacturing & logistics",
          "doc_count": 18424
        },
        {
          "key": "sales & marketing",
          "doc_count": 17766
        },
        {
          "key": "life sciences",
          "doc_count": 15134
        },
        {
          "key": "engineering",
          "doc_count": 14805
        },
        {
          "key": "human resources",
          "doc_count": 12831
        },
        {
          "key": "business administration & operation",
          "doc_count": 12173
        }
      ]
    }
  }
}

Your Environment

  • node version: v20.11.1
  • @elastic/elasticsearch version: 8.11.1
  • os: Mac,
@JoshMock
Copy link
Member

You're looking for res?.aggregations?.unique_val but your response clearly shows res?.aggregations?.unique_industries. Is that a typo, or could that be your underlying issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants