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

[BUG] Missing aggs property for search. #977

Open
xavianaxw opened this issue Feb 14, 2025 · 5 comments
Open

[BUG] Missing aggs property for search. #977

xavianaxw opened this issue Feb 14, 2025 · 5 comments
Assignees

Comments

@xavianaxw
Copy link

What is the bug?

Related to #956 , should aggs be supported in nested aggregations?

How can one reproduce the bug?

await client.search({
  index: 'news',
  body: {
    query: {
      bool: {
        filter: [
          { term: { 'locale.keyword': 'en' } },
        ],
      },
    },
    aggs: {
      spendAggregationsByCurrency: {
        terms: {
          field: 'currency.keyword',
        },
        aggs: { <-- throws error 'aggs' does not exist in type 'AggregationContainer'
          totalSpend: {
            sum: {
              field: 'adCost',
            },
          },
       }, 
    },
    size: 0,
  },
})

What is the expected behavior?

For aggs to be supported

Do you have any screenshots?

Image

Additional question

Considering the big release of opensearch-project v3 was revolved around the opensearch API specification generator, should it only support aggregations moving forward? or aggs is expected to continue working?

@dblock
Copy link
Member

dblock commented Feb 14, 2025

Considering the big release of opensearch-project v3 was revolved around the opensearch API specification generator, should it only support aggregations moving forward? or aggs is expected to continue working?

If the server still supports it then yes. Please do contribute!

@xavianaxw
Copy link
Author

Shall we close this issue @Xtansia ?

@Xtansia
Copy link
Contributor

Xtansia commented Feb 25, 2025

@xavianaxw Should likely leave the issue open until the changed spec actually gets pulled in via the next code generation run. (cc @nhtruong)

@andrross
Copy link
Member

Catch All Triage - 1

@nhtruong nhtruong changed the title [BUG] [BUG] Missing aggs property for search. Mar 10, 2025
@nhtruong
Copy link
Collaborator

nhtruong commented Mar 10, 2025

@xavianaxw the codegen is having trouble handling the edge case of nested oneOf within allOf. This will have to be treated as an edge case since the codegen does not assume that all sub-schemas of oneOf are of the same type (i.e. object in this case), but we must have a guard to detect if they are all objects. so it can collect all properties within oneOf and put them in the same object. Note that there's no 1 to 1 translation from JSON Schemas to TS types, so the best-effort in this case is an object with all properties defined within allOf and its nested oneOf. I'll take care of it.

@nhtruong nhtruong self-assigned this Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants