@@ -167,7 +167,24 @@ public static ProjectionDefinition<TDocument> Meta<TDocument>(this ProjectionDef
167
167
/// </returns>
168
168
public static ProjectionDefinition < TDocument > MetaSearchHighlights < TDocument > (
169
169
this ProjectionDefinition < TDocument > projection ,
170
- string field )
170
+ FieldDefinition < TDocument > field )
171
+ {
172
+ var builder = Builders < TDocument > . Projection ;
173
+ return builder . Combine ( projection , builder . MetaSearchHighlights ( field ) ) ;
174
+ }
175
+
176
+ /// <summary>
177
+ /// Combines an existing projection with a search highlights projection.
178
+ /// </summary>
179
+ /// <typeparam name="TDocument">The type of the document.</typeparam>
180
+ /// <param name="projection">The projection.</param>
181
+ /// <param name="field">The field.</param>
182
+ /// <returns>
183
+ /// A combined projection.
184
+ /// </returns>
185
+ public static ProjectionDefinition < TDocument > MetaSearchHighlights < TDocument > (
186
+ this ProjectionDefinition < TDocument > projection ,
187
+ Expression < Func < TDocument , object > > field )
171
188
{
172
189
var builder = Builders < TDocument > . Projection ;
173
190
return builder . Combine ( projection , builder . MetaSearchHighlights ( field ) ) ;
@@ -184,12 +201,46 @@ public static ProjectionDefinition<TDocument> MetaSearchHighlights<TDocument>(
184
201
/// </returns>
185
202
public static ProjectionDefinition < TDocument > MetaSearchScore < TDocument > (
186
203
this ProjectionDefinition < TDocument > projection ,
187
- string field )
204
+ FieldDefinition < TDocument > field )
188
205
{
189
206
var builder = Builders < TDocument > . Projection ;
190
207
return builder . Combine ( projection , builder . MetaSearchScore ( field ) ) ;
191
208
}
192
209
210
+ /// <summary>
211
+ /// Combines an existing projection with a search score projection.
212
+ /// </summary>
213
+ /// <typeparam name="TDocument">The type of the document.</typeparam>
214
+ /// <param name="projection">The projection.</param>
215
+ /// <param name="field">The field.</param>
216
+ /// <returns>
217
+ /// A combined projection.
218
+ /// </returns>
219
+ public static ProjectionDefinition < TDocument > MetaSearchScore < TDocument > (
220
+ this ProjectionDefinition < TDocument > projection ,
221
+ Expression < Func < TDocument , object > > field )
222
+ {
223
+ var builder = Builders < TDocument > . Projection ;
224
+ return builder . Combine ( projection , builder . MetaSearchScore ( field ) ) ;
225
+ }
226
+
227
+ /// <summary>
228
+ /// Combines an existing projection with a search score details projection.
229
+ /// </summary>
230
+ /// <typeparam name="TDocument">The type of the document.</typeparam>
231
+ /// <param name="projection">The projection.</param>
232
+ /// <param name="field">The field.</param>
233
+ /// <returns>
234
+ /// A combined projection.
235
+ /// </returns>
236
+ public static ProjectionDefinition < TDocument > MetaSearchScoreDetails < TDocument > (
237
+ this ProjectionDefinition < TDocument > projection ,
238
+ FieldDefinition < TDocument > field )
239
+ {
240
+ var builder = Builders < TDocument > . Projection ;
241
+ return builder . Combine ( projection , builder . MetaSearchScoreDetails ( field ) ) ;
242
+ }
243
+
193
244
/// <summary>
194
245
/// Combines an existing projection with a search score details projection.
195
246
/// </summary>
@@ -201,7 +252,7 @@ public static ProjectionDefinition<TDocument> MetaSearchScore<TDocument>(
201
252
/// </returns>
202
253
public static ProjectionDefinition < TDocument > MetaSearchScoreDetails < TDocument > (
203
254
this ProjectionDefinition < TDocument > projection ,
204
- string field )
255
+ Expression < Func < TDocument , object > > field )
205
256
{
206
257
var builder = Builders < TDocument > . Projection ;
207
258
return builder . Combine ( projection , builder . MetaSearchScoreDetails ( field ) ) ;
@@ -216,12 +267,65 @@ public static ProjectionDefinition<TDocument> MetaSearchScoreDetails<TDocument>(
216
267
/// <returns>
217
268
/// A combined projection.
218
269
/// </returns>
219
- public static ProjectionDefinition < TDocument > MetaTextScore < TDocument > ( this ProjectionDefinition < TDocument > projection , string field )
270
+ public static ProjectionDefinition < TDocument > MetaTextScore < TDocument > (
271
+ this ProjectionDefinition < TDocument > projection ,
272
+ FieldDefinition < TDocument > field )
220
273
{
221
274
var builder = Builders < TDocument > . Projection ;
222
275
return builder . Combine ( projection , builder . MetaTextScore ( field ) ) ;
223
276
}
224
277
278
+ /// <summary>
279
+ /// Combines an existing projection with a text score projection.
280
+ /// </summary>
281
+ /// <typeparam name="TDocument">The type of the document.</typeparam>
282
+ /// <param name="projection">The projection.</param>
283
+ /// <param name="field">The field.</param>
284
+ /// <returns>
285
+ /// A combined projection.
286
+ /// </returns>
287
+ public static ProjectionDefinition < TDocument > MetaTextScore < TDocument > (
288
+ this ProjectionDefinition < TDocument > projection ,
289
+ Expression < Func < TDocument , object > > field )
290
+ {
291
+ var builder = Builders < TDocument > . Projection ;
292
+ return builder . Combine ( projection , builder . MetaTextScore ( field ) ) ;
293
+ }
294
+
295
+ /// <summary>
296
+ /// Combines an existing projection with a VectorSearch score projection.
297
+ /// </summary>
298
+ /// <typeparam name="TDocument">The type of the document.</typeparam>
299
+ /// <param name="projection">The projection.</param>
300
+ /// <param name="field">The field.</param>
301
+ /// <returns>
302
+ /// A combined projection.
303
+ /// </returns>
304
+ public static ProjectionDefinition < TDocument > MetaVectorSearchScore < TDocument > (
305
+ this ProjectionDefinition < TDocument > projection ,
306
+ FieldDefinition < TDocument > field )
307
+ {
308
+ var builder = Builders < TDocument > . Projection ;
309
+ return builder . Combine ( projection , builder . MetaVectorSearchScore ( field ) ) ;
310
+ }
311
+
312
+ /// <summary>
313
+ /// Combines an existing projection with a VectorSearch score projection.
314
+ /// </summary>
315
+ /// <typeparam name="TDocument">The type of the document.</typeparam>
316
+ /// <param name="projection">The projection.</param>
317
+ /// <param name="field">The field.</param>
318
+ /// <returns>
319
+ /// A combined projection.
320
+ /// </returns>
321
+ public static ProjectionDefinition < TDocument > MetaVectorSearchScore < TDocument > (
322
+ this ProjectionDefinition < TDocument > projection ,
323
+ Expression < Func < TDocument , object > > field )
324
+ {
325
+ var builder = Builders < TDocument > . Projection ;
326
+ return builder . Combine ( projection , builder . MetaVectorSearchScore ( field ) ) ;
327
+ }
328
+
225
329
/// <summary>
226
330
/// Combines an existing projection with a search metadata projection.
227
331
/// </summary>
@@ -475,7 +579,7 @@ public ProjectionDefinition<TSource> Include(Expression<Func<TSource, object>> f
475
579
/// <returns>
476
580
/// A text score projection.
477
581
/// </returns>
478
- public ProjectionDefinition < TSource > Meta ( string field , string metaFieldName )
582
+ public ProjectionDefinition < TSource > Meta ( FieldDefinition < TSource > field , string metaFieldName )
479
583
{
480
584
return new SingleFieldProjectionDefinition < TSource > ( field , new BsonDocument ( "$meta" , metaFieldName ) ) ;
481
585
}
@@ -487,47 +591,119 @@ public ProjectionDefinition<TSource> Meta(string field, string metaFieldName)
487
591
/// <returns>
488
592
/// A search highlights projection.
489
593
/// </returns>
490
- public ProjectionDefinition < TSource > MetaSearchHighlights ( string field )
594
+ public ProjectionDefinition < TSource > MetaSearchHighlights ( FieldDefinition < TSource > field )
491
595
{
492
596
return Meta ( field , "searchHighlights" ) ;
493
597
}
494
598
599
+ /// <summary>
600
+ /// Creates a search highlights projection.
601
+ /// </summary>
602
+ /// <param name="field">The field.</param>
603
+ /// <returns>
604
+ /// A search highlights projection.
605
+ /// </returns>
606
+ public ProjectionDefinition < TSource > MetaSearchHighlights < TField > ( Expression < Func < TSource , TField > > field )
607
+ {
608
+ return MetaSearchHighlights ( new ExpressionFieldDefinition < TSource > ( field ) ) ;
609
+ }
610
+
495
611
/// <summary>
496
612
/// Creates a search score projection.
497
613
/// </summary>
498
614
/// <param name="field">The field.</param>
499
615
/// <returns>
500
616
/// A search score projection.
501
617
/// </returns>
502
- public ProjectionDefinition < TSource > MetaSearchScore ( string field )
618
+ public ProjectionDefinition < TSource > MetaSearchScore ( FieldDefinition < TSource > field )
503
619
{
504
620
return Meta ( field , "searchScore" ) ;
505
621
}
506
622
623
+ /// <summary>
624
+ /// Creates a search score projection.
625
+ /// </summary>
626
+ /// <param name="field">The field.</param>
627
+ /// <returns>
628
+ /// A search score projection.
629
+ /// </returns>
630
+ public ProjectionDefinition < TSource > MetaSearchScore < TField > ( Expression < Func < TSource , TField > > field )
631
+ {
632
+ return MetaSearchScore ( new ExpressionFieldDefinition < TSource > ( field ) ) ;
633
+ }
634
+
507
635
/// <summary>
508
636
/// Creates a search score details projection.
509
637
/// </summary>
510
638
/// <param name="field">The field.</param>
511
639
/// <returns>
512
640
/// A search score details projection.
513
641
/// </returns>
514
- public ProjectionDefinition < TSource > MetaSearchScoreDetails ( string field )
642
+ public ProjectionDefinition < TSource > MetaSearchScoreDetails ( FieldDefinition < TSource > field )
515
643
{
516
644
return Meta ( field , "searchScoreDetails" ) ;
517
645
}
518
646
647
+ /// <summary>
648
+ /// Creates a search score details projection.
649
+ /// </summary>
650
+ /// <param name="field">The field.</param>
651
+ /// <returns>
652
+ /// A search score details projection.
653
+ /// </returns>
654
+ public ProjectionDefinition < TSource > MetaSearchScoreDetails < TField > ( Expression < Func < TSource , TField > > field )
655
+ {
656
+ return MetaSearchScoreDetails ( new ExpressionFieldDefinition < TSource > ( field ) ) ;
657
+ }
658
+
519
659
/// <summary>
520
660
/// Creates a text score projection.
521
661
/// </summary>
522
662
/// <param name="field">The field.</param>
523
663
/// <returns>
524
664
/// A text score projection.
525
665
/// </returns>
526
- public ProjectionDefinition < TSource > MetaTextScore ( string field )
666
+ public ProjectionDefinition < TSource > MetaTextScore ( FieldDefinition < TSource > field )
527
667
{
528
668
return Meta ( field , "textScore" ) ;
529
669
}
530
670
671
+ /// <summary>
672
+ /// Creates a text score projection.
673
+ /// </summary>
674
+ /// <param name="field">The field.</param>
675
+ /// <returns>
676
+ /// A text score projection.
677
+ /// </returns>
678
+ public ProjectionDefinition < TSource > MetaTextScore < TField > ( Expression < Func < TSource , TField > > field )
679
+ {
680
+ return MetaTextScore ( new ExpressionFieldDefinition < TSource > ( field ) ) ;
681
+ }
682
+
683
+ /// <summary>
684
+ /// Creates a VectorSearch score projection.
685
+ /// </summary>
686
+ /// <param name="field">The field.</param>
687
+ /// <returns>
688
+ /// A VectorSearch score projection.
689
+ /// </returns>
690
+ public ProjectionDefinition < TSource > MetaVectorSearchScore ( FieldDefinition < TSource > field )
691
+ {
692
+ return Meta ( field , "vectorSearchScore" ) ;
693
+ }
694
+
695
+ /// <summary>
696
+ /// Creates a VectorSearch score projection.
697
+ /// </summary>
698
+ /// <param name="field">The field.</param>
699
+ /// <returns>
700
+ /// A VectorSearch score projection.
701
+ /// </returns>
702
+ public ProjectionDefinition < TSource > MetaVectorSearchScore < TField > ( Expression < Func < TSource , TField > > field )
703
+ {
704
+ return MetaVectorSearchScore ( new ExpressionFieldDefinition < TSource > ( field ) ) ;
705
+ }
706
+
531
707
/// <summary>
532
708
/// Creates a search metadata projection.
533
709
/// </summary>
0 commit comments