Skip to content

Expose the method to get total shards & successful shards from SearchHits response #2605

Closed
@balram1988

Description

@balram1988

Hi Team,

We have one use case where we have to check and need to do some handling on the basis of total shards and successful shards. So it will be good if we can expose them from org.springframework.data.elasticsearch.core.SearchHits

`/*
public interface SearchHits extends Streamable<SearchHit> {

/**
 * @return the aggregations.
 */
@Nullable
AggregationsContainer<?> getAggregations();

/**
 * @return the maximum score
 */
float getMaxScore();

/**
 * @param index position in List.
 * @return the {@link SearchHit} at position {index}
 * @throws IndexOutOfBoundsException on invalid index
 */
SearchHit<T> getSearchHit(int index);

/**
 * @return the contained {@link SearchHit}s.
 */
List<SearchHit<T>> getSearchHits();

/**
 * @return the number of total hits.
 */
long getTotalHits();

/**
 * @return the relation for the total hits
 */
TotalHitsRelation getTotalHitsRelation();

/**
 * @return true if aggregations are available
 */
default boolean hasAggregations() {
	return getAggregations() != null;
}

/**
 * @return whether the {@link SearchHits} has search hits.
 */
default boolean hasSearchHits() {
	return !getSearchHits().isEmpty();
}

/**
 * @return the suggest response
 * @since 4.3
 */
@Nullable
Suggest getSuggest();

/**
 * @return wether the {@link SearchHits} has a suggest response.
 * @since 4.3
 */
default boolean hasSuggest() {
	return getSuggest() != null;
}

/**
 * @return an iterator for {@link SearchHit}
 */
default Iterator<SearchHit<T>> iterator() {
	return getSearchHits().iterator();
}

}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions