diff --git a/src/Nest/Search/Search/SearchResponse.cs b/src/Nest/Search/Search/SearchResponse.cs index 68e6a0914cf..ce96fa62a08 100644 --- a/src/Nest/Search/Search/SearchResponse.cs +++ b/src/Nest/Search/Search/SearchResponse.cs @@ -8,94 +8,99 @@ namespace Nest { public interface ISearchResponse : IResponse where T : class { - /// - /// Gets the meta data about the shards on which the search query was executed. - /// - ShardsMetaData Shards { get; } - - /// - /// Gets the meta data about the hits that match the search query criteria. - /// - HitsMetaData HitsMetaData { get; } - - /// - /// Gets the collection of aggregations - /// - IReadOnlyDictionary Aggregations { get; } - - /// - /// Gets the results of profiling the search query. Has a value only when - /// is set to true on the search request. - /// - Profile Profile { get; } - - /// - /// Gets the aggregations helper that can be used to more easily handle aggregation - /// results. - /// - AggregationsHelper Aggs { get; } - - /// - /// Gets the suggester results. - /// - IReadOnlyDictionary[]> Suggest { get; } - - /// - /// Time in milliseconds for Elasticsearch to execute the search - /// - long Took { get; } - - /// - /// Gets a value indicating whether the search timed out or not - /// - bool TimedOut { get; } - - /// - /// Gets a value indicating whether the search was terminated early - /// - bool TerminatedEarly { get; } - - /// - /// Gets the scroll id which can be passed to the Scroll API in order to retrieve the next batch - /// of results. Has a value only when is specified on the - /// search request - /// - string ScrollId { get; } - - /// - /// Gets the total number of documents matching the search query criteria - /// - long Total { get; } - - /// - /// Gets the maximum score for documents matching the search query criteria - /// - double MaxScore { get; } - - /// - /// Gets the documents inside the hits, by deserializing into T. - /// NOTE: if you use on the search request, - /// will be empty and you should use - /// instead to get the field values. As an alternative to - /// , try source filtering using on the - /// search request to return with partial fields selected - /// - /// - IReadOnlyCollection Documents { get; } - - /// - /// Gets the collection of hits that matched the query - /// - /// - /// The hits. - /// - IReadOnlyCollection> Hits { get; } - - /// - /// Gets the field values inside the hits, when the search request uses - /// . - /// - IReadOnlyCollection Fields { get; } + /// + /// Gets the meta data about the shards on which the search query was executed. + /// + ShardsMetaData Shards { get; } + + /// + /// Gets the meta data about the hits that match the search query criteria. + /// + HitsMetaData HitsMetaData { get; } + + /// + /// Gets the collection of aggregations + /// + IReadOnlyDictionary Aggregations { get; } + + /// + /// Gets the results of profiling the search query. Has a value only when + /// is set to true on the search request. + /// + Profile Profile { get; } + + /// + /// Gets the aggregations helper that can be used to more easily handle aggregation + /// results. + /// + AggregationsHelper Aggs { get; } + + /// + /// Gets the suggester results. + /// + IReadOnlyDictionary[]> Suggest { get; } + + /// + /// Time in milliseconds for Elasticsearch to execute the search + /// + long Took { get; } + + /// + /// Gets a value indicating whether the search timed out or not + /// + bool TimedOut { get; } + + /// + /// Gets a value indicating whether the search was terminated early + /// + bool TerminatedEarly { get; } + + /// + /// Gets the scroll id which can be passed to the Scroll API in order to retrieve the next batch + /// of results. Has a value only when is specified on the + /// search request + /// + string ScrollId { get; } + + /// + /// Gets the total number of documents matching the search query criteria + /// + long Total { get; } + + /// + /// Gets the maximum score for documents matching the search query criteria + /// + double MaxScore { get; } + + /// + /// Number of times the server performed an incremental reduce phase + /// + long NumberOfReducePhases { get; } + + /// + /// Gets the documents inside the hits, by deserializing into T. + /// NOTE: if you use on the search request, + /// will be empty and you should use + /// instead to get the field values. As an alternative to + /// , try source filtering using on the + /// search request to return with partial fields selected + /// + /// + IReadOnlyCollection Documents { get; } + + /// + /// Gets the collection of hits that matched the query + /// + /// + /// The hits. + /// + IReadOnlyCollection> Hits { get; } + + /// + /// Gets the field values inside the hits, when the search request uses + /// . + /// + IReadOnlyCollection Fields { get; } } [JsonObject] @@ -115,6 +120,7 @@ public class SearchResponse : ResponseBase, ISearchResponse where T : clas public Profile Profile { get; internal set; } private AggregationsHelper _agg; + [JsonIgnore] public AggregationsHelper Aggs => _agg ?? (_agg = new AggregationsHelper(this.Aggregations)); @@ -140,6 +146,9 @@ public class SearchResponse : ResponseBase, ISearchResponse where T : clas [JsonProperty(PropertyName = "hits")] public HitsMetaData HitsMetaData { get; internal set; } + [JsonProperty(PropertyName = "num_reduce_phases")] + public long NumberOfReducePhases { get; internal set; } + [JsonIgnore] public long Total => this.HitsMetaData?.Total ?? 0; @@ -147,6 +156,7 @@ public class SearchResponse : ResponseBase, ISearchResponse where T : clas public double MaxScore => this.HitsMetaData?.MaxScore ?? 0; private IReadOnlyCollection _documents; + /// [JsonIgnore] public IReadOnlyCollection Documents => @@ -155,6 +165,7 @@ public class SearchResponse : ResponseBase, ISearchResponse where T : clas .ToList()); private IReadOnlyCollection> _hits; + [JsonIgnore] public IReadOnlyCollection> Hits => this._hits ?? (this._hits = this.HitsMetaData?.Hits ?? EmptyReadOnly>.Collection); @@ -163,9 +174,8 @@ public class SearchResponse : ResponseBase, ISearchResponse where T : clas /// public IReadOnlyCollection Fields => - this._fields ?? (this._fields = this.Hits - .Select(h => h.Fields) - .ToList()); - + this._fields ?? (this._fields = this.Hits + .Select(h => h.Fields) + .ToList()); } }