Skip to content

Commit

Permalink
Add successfulSearchShardIndices in searchRequestContext before onReq…
Browse files Browse the repository at this point in the history
…uestEnd (opensearch-project#15967)

Signed-off-by: David Zane <[email protected]>
Signed-off-by: Ankit Jain <[email protected]>
Co-authored-by: Ankit Jain <[email protected]>
  • Loading branch information
2 people authored and dk2k committed Oct 17, 2024
1 parent 39e8ca1 commit 6511476
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Workload Management] QueryGroup resource cancellation framework changes ([#15651](https://github.com/opensearch-project/OpenSearch/pull/15651))
- Fallback to Remote cluster-state on Term-Version check mismatch - ([#15424](https://github.com/opensearch-project/OpenSearch/pull/15424))
- Implement WithFieldName interface in ValuesSourceAggregationBuilder & FieldSortBuilder ([#15916](https://github.com/opensearch-project/OpenSearch/pull/15916))
- Add successfulSearchShardIndices in searchRequestContext ([#15967](https://github.com/opensearch-project/OpenSearch/pull/15967))
- Remove identity-related feature flagged code from the RestController ([#15430](https://github.com/opensearch-project/OpenSearch/pull/15430))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,9 @@ public void sendSearchResponse(InternalSearchResponse internalSearchResponse, At
}
searchRequestContext.setTotalHits(internalSearchResponse.hits().getTotalHits());
searchRequestContext.setShardStats(results.getNumShards(), successfulOps.get(), skippedOps.get(), failures.length);
searchRequestContext.setSuccessfulSearchShardIndices(
results.getSuccessfulResults().map(result -> result.getSearchShardTarget().getIndex()).collect(Collectors.toSet())
);
onPhaseEnd(searchRequestContext);
onRequestEnd(searchRequestContext);
listener.onResponse(buildSearchResponse(internalSearchResponse, failures, scrollId, searchContextId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Supplier;

Expand All @@ -36,6 +37,7 @@ public class SearchRequestContext {
private final Map<String, Long> phaseTookMap;
private TotalHits totalHits;
private final EnumMap<ShardStatsFieldNames, Integer> shardStats;
private Set<String> successfulSearchShardIndices;

private final SearchRequest searchRequest;
private final LinkedBlockingQueue<TaskResourceInfo> phaseResourceUsage;
Expand Down Expand Up @@ -141,6 +143,18 @@ public List<TaskResourceInfo> getPhaseResourceUsage() {
public SearchRequest getRequest() {
return searchRequest;
}

void setSuccessfulSearchShardIndices(Set<String> successfulSearchShardIndices) {
this.successfulSearchShardIndices = successfulSearchShardIndices;
}

/**
* @return A {@link List} of {@link String} representing the names of the indices that were
* successfully queried at the shard level.
*/
public Set<String> getSuccessfulSearchShardIndices() {
return successfulSearchShardIndices;
}
}

enum ShardStatsFieldNames {
Expand Down

0 comments on commit 6511476

Please sign in to comment.