Skip to content

Conversation

@natea
Copy link

@natea natea commented Aug 15, 2025

Summary

This PR adds support for the stats parameter to the count API, providing feature parity with the search API. The stats parameter allows tagging count requests for logging and statistical purposes.

Changes

  • Added stats parameter parsing in RestCountAction.java
  • Updated count.json API specification to include stats parameter
  • Added comprehensive unit tests in RestCountActionTests.java

Implementation Details

The implementation follows the existing pattern used in RestSearchAction, passing the stats parameter through to the underlying SearchSourceBuilder. Since the count API internally uses the search API infrastructure, this was a straightforward addition requiring minimal code changes.

Testing

  • Added unit tests covering various scenarios:
    • Multiple stats tags
    • Single stats tag
    • Empty stats parameter
    • No stats parameter (default behavior)

Related Issue

Closes #67528

🤖 Generated with Claude Code

This change adds support for the 'stats' parameter to the count API,
providing feature parity with the search API. The stats parameter
allows tagging count requests for logging and statistical purposes.

Changes:
- Added stats parameter parsing in RestCountAction
- Updated count.json API specification to include stats parameter
- Added comprehensive unit tests for stats parameter functionality

The implementation follows the existing pattern used in RestSearchAction,
passing the stats parameter through to the underlying SearchSourceBuilder.

Closes elastic#67528

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label external-contributor Pull request authored by a developer outside the Elasticsearch team v9.2.0 labels Aug 15, 2025
@gareth-ellis gareth-ellis added :Core/Infra/REST API REST infrastructure and utilities and removed needs:triage Requires assignment of a team area label labels Aug 15, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Aug 15, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@gareth-ellis gareth-ellis added >enhancement and removed Team:Core/Infra Meta label for core/infra team labels Aug 15, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Aug 15, 2025
@ldematte ldematte added :Search Foundations/Search Catch all for Search Foundations and removed Team:Core/Infra Meta label for core/infra team :Core/Infra/REST API REST infrastructure and utilities labels Aug 18, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Aug 18, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this PR, I left one comment on testing, the change itself looks good.

import static org.hamcrest.Matchers.hasItems;
import static org.mockito.Mockito.mock;

public final class RestCountActionTests extends RestActionTestCase {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should rather add a yaml test for this. The outcome is very similar. Yet the yaml tests are also run by clients and help verify that the new parameter is support by clients too (and not only by ES)

@javanna javanna self-assigned this Aug 18, 2025
@javanna
Copy link
Member

javanna commented Aug 18, 2025

test this please

@javanna
Copy link
Member

javanna commented Sep 15, 2025

Hello @natea are you interested in getting this merged? I reviewed this a while back.

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

Labels

>enhancement external-contributor Pull request authored by a developer outside the Elasticsearch team :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement stats parameter for count queries

5 participants