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

Fix: Implements generic aggregations for multisearch #1938

Closed
wants to merge 1 commit into from

Conversation

hoiekim
Copy link

@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
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
Copy link
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
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