Skip to content

Commit fee61f3

Browse files
committed
- PR comments
1 parent 41e5770 commit fee61f3

File tree

3 files changed

+98
-28
lines changed

3 files changed

+98
-28
lines changed

src/MongoDB.Driver/Search/SearchHighlight.cs

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,37 @@ namespace MongoDB.Driver.Search
2424
public sealed class SearchHighlight
2525
{
2626
/// <summary>
27-
/// Gets or sets the document field which returned a match.
27+
/// Initializes a new instance of the <see cref="SearchHighlight"/> class.
2828
/// </summary>
29-
[BsonElement("path")]
30-
public string Path { get; private set; }
29+
/// <param name="path">document field which returned a match.</param>
30+
/// <param name="score">Score assigned to this result.</param>
31+
/// <param name="texts">Objects containing the matching text and the surrounding text.</param>
32+
public SearchHighlight(string path, double score, SearchHighlightText[] texts)
33+
{
34+
Path = path;
35+
Score = score;
36+
Texts = texts;
37+
}
3138

3239
/// <summary>
33-
/// Gets or sets one or more objects containing the matching text and the surrounding text
34-
/// (if any).
40+
/// Gets the document field which returned a match.
3541
/// </summary>
36-
[BsonElement("texts")]
37-
public SearchHighlightText[] Texts { get; private set; }
42+
[BsonElement("path")]
43+
public string Path { get; }
3844

3945
/// <summary>
40-
/// Gets or sets the score assigned to this result.
46+
/// Gets the score assigned to this result.
4147
/// </summary>
4248
[BsonElement("score")]
43-
public double Score { get; private set; }
49+
public double Score { get; }
50+
51+
/// <summary>
52+
/// Gets one or more objects containing the matching text and the surrounding text
53+
/// (if any).
54+
/// </summary>
55+
[BsonDefaultValue(null)]
56+
[BsonElement("texts")]
57+
public SearchHighlightText[] Texts { get; }
4458
}
4559

4660
/// <summary>
@@ -49,17 +63,28 @@ public sealed class SearchHighlight
4963
public sealed class SearchHighlightText
5064
{
5165
/// <summary>
52-
/// Gets or sets the text from the field which returned a match.
66+
/// Initializes a new instance of the <see cref="SearchHighlightText"/> class.
5367
/// </summary>
54-
[BsonElement("value")]
55-
public string Value { get; private set; }
68+
/// <param name="type">Type of search highlight.</param>
69+
/// <param name="value">Text from the field which returned a match.</param>
70+
public SearchHighlightText(HighlightTextType type, string value)
71+
{
72+
Type = type;
73+
Value = value;
74+
}
5675

5776
/// <summary>
5877
/// Gets or sets the type of text, matching or surrounding.
5978
/// </summary>
6079
[BsonElement("type")]
6180
[BsonRepresentation(BsonType.String)]
62-
public HighlightTextType Type { get; private set; }
81+
public HighlightTextType Type { get; }
82+
83+
/// <summary>
84+
/// Gets the text from the field which returned a match.
85+
/// </summary>
86+
[BsonElement("value")]
87+
public string Value { get; }
6388
}
6489

6590
/// <summary>

src/MongoDB.Driver/Search/SearchMetaResult.cs

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,29 @@ namespace MongoDB.Driver.Search
2525
public sealed class SearchMetaCountResult
2626
{
2727
/// <summary>
28-
/// Gets or sets the lower bound for this result set.
28+
/// Initializes a new instance of the <see cref="SearchMetaCountResult"/> class.
2929
/// </summary>
30+
/// <param name="lowerBound">Lower bound for this result set.</param>
31+
/// <param name="total">Total for this result set.</param>
32+
public SearchMetaCountResult(long? lowerBound, long? total)
33+
{
34+
LowerBound = lowerBound;
35+
Total = total;
36+
}
37+
38+
/// <summary>
39+
/// Gets the lower bound for this result set.
40+
/// </summary>
41+
[BsonDefaultValue(null)]
3042
[BsonElement("lowerBound")]
31-
public long? LowerBound { get; private set; }
43+
public long? LowerBound { get; }
3244

3345
/// <summary>
34-
/// Gets or sets the total for this result set.
46+
/// Gets the total for this result set.
3547
/// </summary>
48+
[BsonDefaultValue(null)]
3649
[BsonElement("total")]
37-
public long? Total { get; private set; }
50+
public long? Total { get; }
3851
}
3952

4053
/// <summary>
@@ -43,16 +56,27 @@ public sealed class SearchMetaCountResult
4356
public sealed class SearchMetaFacetBucketResult
4457
{
4558
/// <summary>
46-
/// Gets or sets the count of documents in this facet bucket.
59+
/// Initializes a new instance of the <see cref="SearchMetaFacetBucketResult"/> class.
60+
/// </summary>
61+
/// <param name="count">count of documents in this facet bucket.</param>
62+
/// <param name="id">Unique identifier that identifies this facet bucket.</param>
63+
public SearchMetaFacetBucketResult(long count, BsonValue id)
64+
{
65+
Count = count;
66+
Id = id;
67+
}
68+
69+
/// <summary>
70+
/// Gets the count of documents in this facet bucket.
4771
/// </summary>
4872
[BsonElement("count")]
49-
public long Count { get; private set; }
73+
public long Count { get; }
5074

5175
/// <summary>
52-
/// Gets or sets the unique identifier that identifies this facet bucket.
76+
/// Gets the unique identifier that identifies this facet bucket.
5377
/// </summary>
5478
[BsonId]
55-
public BsonValue Id { get; private set; }
79+
public BsonValue Id { get; }
5680
}
5781

5882
/// <summary>
@@ -61,10 +85,19 @@ public sealed class SearchMetaFacetBucketResult
6185
public sealed class SearchMetaFacetResult
6286
{
6387
/// <summary>
64-
/// Gets or sets a list of bucket result sets.
88+
/// Initializes a new instance of the <see cref="SearchMetaFacetResult"/> class.
89+
/// </summary>
90+
/// <param name="buckets">An array of bucket result sets.</param>
91+
public SearchMetaFacetResult(SearchMetaFacetBucketResult[] buckets)
92+
{
93+
Buckets = buckets;
94+
}
95+
96+
/// <summary>
97+
/// Gets an array of bucket result sets.
6598
/// </summary>
6699
[BsonElement("buckets")]
67-
public List<SearchMetaFacetBucketResult> Buckets { get; private set; }
100+
public SearchMetaFacetBucketResult[] Buckets { get; }
68101
}
69102

70103
/// <summary>
@@ -73,15 +106,28 @@ public sealed class SearchMetaFacetResult
73106
public sealed class SearchMetaResult
74107
{
75108
/// <summary>
76-
/// Gets or sets the count result set.
109+
/// Initializes a new instance of the <see cref="SearchMetaResult"/> class.
110+
/// </summary>
111+
/// <param name="count">Count result set.</param>
112+
/// <param name="facet">Facet result sets.</param>
113+
public SearchMetaResult(SearchMetaCountResult count, IReadOnlyDictionary<string, SearchMetaFacetResult> facet)
114+
{
115+
Count = count;
116+
Facet = facet;
117+
}
118+
119+
/// <summary>
120+
/// Gets the count result set.
77121
/// </summary>
122+
[BsonDefaultValue(null)]
78123
[BsonElement("count")]
79-
public SearchMetaCountResult Count { get; private set; }
124+
public SearchMetaCountResult Count { get; }
80125

81126
/// <summary>
82-
/// Gets or sets the facet result sets.
127+
/// Gets the facet result sets.
83128
/// </summary>
129+
[BsonDefaultValue(null)]
84130
[BsonElement("facet")]
85-
public Dictionary<string, SearchMetaFacetResult> Facet { get; private set; }
131+
public IReadOnlyDictionary<string, SearchMetaFacetResult> Facet { get; }
86132
}
87133
}

tests/MongoDB.Driver.Tests/Search/AtlasSearchTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ public void SearchMeta_facet()
370370
.Single();
371371

372372
result.Should().NotBeNull();
373-
result.Facet.Should().NotBeNull().And.ContainKeys("date", "number", "string");
374373

375374
var bucket = result.Facet["string"].Buckets.Should().NotBeNull().And.ContainSingle().Subject;
376375
bucket.Id.Should().Be((BsonString)"machine");

0 commit comments

Comments
 (0)