Polishing

This commit is contained in:
Peter-Josef Meisch 2023-12-28 13:53:42 +01:00
parent 433d52981e
commit b0c97ccf27
No known key found for this signature in database
GPG Key ID: DE108246970C7708
4 changed files with 18 additions and 25 deletions

View File

@ -121,8 +121,7 @@ class ResponseConverter {
.build(); .build();
} }
private TemplateResponseData clusterGetComponentTemplateData( private TemplateResponseData clusterGetComponentTemplateData(ComponentTemplateSummary componentTemplateSummary) {
ComponentTemplateSummary componentTemplateSummary) {
var mapping = typeMapping(componentTemplateSummary.mappings()); var mapping = typeMapping(componentTemplateSummary.mappings());
var settings = new Settings(); var settings = new Settings();

View File

@ -169,11 +169,10 @@ class SearchDocumentResponseBuilder {
private static SearchShardStatistics shardsFrom(ShardStatistics shards) { private static SearchShardStatistics shardsFrom(ShardStatistics shards) {
List<ShardFailure> failures = shards.failures(); List<ShardFailure> failures = shards.failures();
List<SearchShardStatistics.Failure> searchFailures = failures.stream() List<SearchShardStatistics.Failure> searchFailures = failures.stream().map(f -> SearchShardStatistics.Failure
.map(f -> SearchShardStatistics.Failure.of(f.index(), f.node(), f.status(), f.shard(), null, .of(f.index(), f.node(), f.status(), f.shard(), null, ResponseConverter.toErrorCause(f.reason()))).toList();
ResponseConverter.toErrorCause(f.reason()))) return SearchShardStatistics.of(shards.failed(), shards.successful(), shards.total(), shards.skipped(),
.toList(); searchFailures);
return SearchShardStatistics.of(shards.failed(), shards.successful(), shards.total(), shards.skipped(), searchFailures);
} }
@Nullable @Nullable
@ -235,9 +234,8 @@ class SearchDocumentResponseBuilder {
var phraseSuggest = suggestionES.phrase(); var phraseSuggest = suggestionES.phrase();
var phraseSuggestOptions = phraseSuggest.options(); var phraseSuggestOptions = phraseSuggest.options();
List<PhraseSuggestion.Entry.Option> options = new ArrayList<>(); List<PhraseSuggestion.Entry.Option> options = new ArrayList<>();
phraseSuggestOptions.forEach(optionES -> options phraseSuggestOptions.forEach(optionES -> options.add(new PhraseSuggestion.Entry.Option(optionES.text(),
.add(new PhraseSuggestion.Entry.Option(optionES.text(), optionES.highlighted(), optionES.score(), optionES.highlighted(), optionES.score(), optionES.collateMatch())));
optionES.collateMatch())));
entries.add(new PhraseSuggestion.Entry(phraseSuggest.text(), phraseSuggest.offset(), phraseSuggest.length(), entries.add(new PhraseSuggestion.Entry(phraseSuggest.text(), phraseSuggest.offset(), phraseSuggest.length(),
options, null)); options, null));
}); });

View File

@ -235,13 +235,13 @@ public class SearchHitMapping<T> {
scrollId = searchHitsImpl.getScrollId(); scrollId = searchHitsImpl.getScrollId();
} }
return new SearchHitsImpl<>(searchHits.getTotalHits(), // return new SearchHitsImpl<>(searchHits.getTotalHits(),
searchHits.getTotalHitsRelation(), // searchHits.getTotalHitsRelation(),
searchHits.getMaxScore(), // searchHits.getMaxScore(),
scrollId, // scrollId,
searchHits.getPointInTimeId(), // searchHits.getPointInTimeId(),
convertedSearchHits, // convertedSearchHits,
searchHits.getAggregations(), // searchHits.getAggregations(),
searchHits.getSuggest(), searchHits.getSuggest(),
searchHits.getSearchShardStatistics()); searchHits.getSearchShardStatistics());
} }

View File

@ -140,16 +140,12 @@ class SearchDocumentResponseBuilderUnitTests {
.shard(1) .shard(1)
.reason(rb -> rb .reason(rb -> rb
.reason("this is a mock failure in shards") .reason("this is a mock failure in shards")
.causedBy(cbb -> .causedBy(cbb -> cbb.reason("inner reason")
cbb.reason("inner reason") .metadata(Map.of("hello", JsonData.of("world"))))
.metadata(Map.of("hello", JsonData.of("world")))
)
.type("reason-type") .type("reason-type")
) )
.status("fail") .status("fail"))))
)
))
.build(); .build();
// act // act