Skip to content

Adds ES searchable snapshots stats#815

Merged
pickypg merged 1 commit intoelastic:mainfrom
albertzaharovits:rest_searchable_snapshots_stats_action
Apr 10, 2025
Merged

Adds ES searchable snapshots stats#815
pickypg merged 1 commit intoelastic:mainfrom
albertzaharovits:rest_searchable_snapshots_stats_action

Conversation

@albertzaharovits
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Member

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM tho why 7.13.0? This API was added in 7.10.0 AFAICT:

$ git show v7.10.0:x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/rest/RestSearchableSnapshotsStatsAction.java
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
package org.elasticsearch.xpack.searchablesnapshots.rest;

import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
import org.elasticsearch.xpack.searchablesnapshots.action.SearchableSnapshotsStatsAction;
import org.elasticsearch.xpack.searchablesnapshots.action.SearchableSnapshotsStatsRequest;

import java.util.List;

import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;

public class RestSearchableSnapshotsStatsAction extends BaseRestHandler {

    @Override
    public List<Route> routes() {
        return unmodifiableList(
            asList(
                new Route(RestRequest.Method.GET, "/_searchable_snapshots/stats"),
                new Route(RestRequest.Method.GET, "/{index}/_searchable_snapshots/stats")
            )
        );
    }

    @Override
    public String getName() {
        return "searchable_snapshots_stats_action";
    }

    @Override
    public RestChannelConsumer prepareRequest(final RestRequest restRequest, final NodeClient client) {
        String[] indices = Strings.splitStringByCommaToArray(restRequest.param("index"));
        return channel -> client.execute(
            SearchableSnapshotsStatsAction.INSTANCE,
            new SearchableSnapshotsStatsRequest(indices),
            new RestToXContentListener<>(channel)
        );
    }
}

@albertzaharovits
Copy link
Copy Markdown
Contributor Author

LGTM tho why 7.13.0? This API was added in 7.10.0 AFAICT:

I picked 7.13 because that's also the ver for searchable snapshot cache stats, and the docs page for searchable snapshot stats https://www.elastic.co/guide/en/elasticsearch/reference/7.13/searchable-snapshots-api-stats.html starts to look right starting in 7.13 . Plus 7.13 is plenty old.

@DaveCTurner
Copy link
Copy Markdown
Member

Plus 7.13 is plenty old.

Yep, shouldn't really matter either way 👍

Copy link
Copy Markdown
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

LGTM

@pickypg pickypg merged commit f59d2b3 into elastic:main Apr 10, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants