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] _cat/indices does not honor bytes option #1459

Closed
cinhtau opened this issue Feb 25, 2025 · 1 comment
Closed

[BUG] _cat/indices does not honor bytes option #1459

cinhtau opened this issue Feb 25, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@cinhtau
Copy link

cinhtau commented Feb 25, 2025

What is the bug?

You can pass the bytes parameter to the _cat/indices API for retrieving the values in your desired unit, here it is bytes.

GET _cat/indices?v&h=index,docs.count,pri.store.size&bytes=b

However, the pri.store.size is empty. Without the bytes option, the value is set in various units.

How can one reproduce the bug?

Example Code

        IndicesRequest indicesRequest = new IndicesRequest.Builder().
        headers("index,docs.count,pri.store.size&bytes=b").sort("creation.date").build();
        IndicesResponse indicesResponse = client.cat().indices(indicesRequest);

        String template = "Index %s has %s documents and uses %s bytes.";

        for (IndicesRecord record : indicesResponse.valueBody()) {
            String formattedString = String.format(template, record.index(),record.docsCount(),record.priStoreSize());
            System.out.println(formattedString);
        }

What is the expected behavior?

pri.store.size should not be null.

What is your host/environment?

na

Do you have any screenshots?

Without option

Index logs-001729 has 130205517 documents and uses 79.5gb bytes.
Index logs-001730 has 131095719 documents and uses 79.8gb bytes.
Index logs-001731 has 130679164 documents and uses 79.7gb bytes.
Index logs-001732 has 133664129 documents and uses 79.9gb bytes.

With option

Index logs-001729 has 130205517 documents and uses null bytes.
Index logs-001730 has 131095719 documents and uses null bytes.
Index logs-001731 has 130679164 documents and uses null bytes.
Index logs-001732 has 133664129 documents and uses null bytes.

Do you have any additional context?

na

@cinhtau cinhtau added bug Something isn't working untriaged labels Feb 25, 2025
@cinhtau
Copy link
Author

cinhtau commented Feb 25, 2025

Reading the Source and Java Docs it had to be done like this

IndicesRequest indicesRequest = new IndicesRequest.Builder().bytes(Bytes.Bytes)
                .headers("index,docs.count,pri.store.size").sort("creation.date").build();

Missing documentation led me to believe it work in Java the same as in DevTools, but passing the option gave me the values in bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants