Skip to content

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

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

Closed
balram1988 opened this issue Jun 27, 2023 · 1 comment · Fixed by #2806
Closed
Labels
type: enhancement A general enhancement

Comments

@balram1988
Copy link

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();
}

}
`

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 27, 2023
@sothawo
Copy link
Collaborator

sothawo commented Jun 27, 2023

Probably might make sense to map the whole ShardStatistics property of the co.elastic.clients.elasticsearch.core.search.ResponseBody and map this into an object of its own.

@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 27, 2023
sothawo pushed a commit that referenced this issue Dec 28, 2023
@sothawo sothawo added this to the 5.3 M1 (2024.0.0) milestone Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants