All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.spinscale.elasticsearch.action.suggest.statistics.SuggestStatisticsResponse Maven / Gradle / Ivy

package de.spinscale.elasticsearch.action.suggest.statistics;

import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastOperationResponse;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.collect.Maps;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public class SuggestStatisticsResponse extends BroadcastOperationResponse {

    private FstStats fstStats = new FstStats();

    public SuggestStatisticsResponse() {}

    public SuggestStatisticsResponse(int totalShards, int successfulShards, int failedShards,
                                     List successfulStatistics,
                                     List shardFailures) {
        super(totalShards, successfulShards, failedShards, shardFailures);

        for (ShardSuggestStatisticsResponse response : successfulStatistics) {
            if (response.getFstIndexShardStats() != null && response.getFstIndexShardStats().size() > 0) {
                fstStats.getStats().addAll(response.getFstIndexShardStats());
            }
        }
    }

    @Override
    public void readFrom(StreamInput in) throws IOException {
        super.readFrom(in);
        fstStats = new FstStats();
        fstStats.readFrom(in);
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        super.writeTo(out);
        fstStats.writeTo(out);
    }

    public FstStats fstStats() {
        return fstStats;
    }
    public FstStats getFstStats() {
        return fstStats;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy