Skip to content

Fix: Implements generic aggregations for multisearch#1938

Closed
hoiekim wants to merge 1 commit intoelastic:mainfrom
hoiekim:msearch-aggregation
Closed

Fix: Implements generic aggregations for multisearch#1938
hoiekim wants to merge 1 commit intoelastic:mainfrom
hoiekim:msearch-aggregation

Conversation

@hoiekim
Copy link
Copy Markdown

@hoiekim hoiekim commented Jul 7, 2023

This PR fixes the following bug (#1937)

import { Client } from "@elastic/elasticsearch";
import { AggregationsTermsAggregateBase } from "@elastic/elasticsearch/lib/api/types";

const client = new Client({ node: "http://localhost:9200" });

const reproduce = async () => {
  interface Doc {
    foo: string;
  }

  interface Aggregations {
    unique: AggregationsTermsAggregateBase<{ key: string }>;
  }

  const response = await client.msearch<Doc, Aggregations>({
    index: "foo",
    searches: [
      {},
      {
        query: { match_all: {} },
        aggregations: { unique: { terms: { field: "foo" } } }
      }
    ]
  });

  response.responses.map((e) => {
    if ("error" in r) return
    return e.aggregations?.unique.buckets;
    //                            ^^^^^^^
    // Property 'buckets' does not exist on type 'AggregationsAggregate'.
    // Property 'buckets' does not exist on type 'AggregationsCardinalityAggregate'.
  });
};

The error will go way with this commit

Similar PR: #1596

@JoshMock
Copy link
Copy Markdown
Member

JoshMock commented Jul 7, 2023

And there's the PR I saw coming. 🙂 I'll take a look soon.

@JoshMock JoshMock self-requested a review July 7, 2023 15:18
@hoiekim hoiekim changed the title Fix: Implements generic aggregations for multisearch (#1937) Fix: Implements generic aggregations for multisearch Jul 7, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 3, 2023

This pull request is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Nov 3, 2023
@JoshMock
Copy link
Copy Markdown
Member

JoshMock commented Nov 3, 2023

Closing. See: #1937 (comment)

@JoshMock JoshMock closed this Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants