[CSHARP-3285] Per-document scoring metadata for $search Created: 08/Dec/20 Updated: 27/May/22 Resolved: 07/Jan/21 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Backlog - Core Eng Program Management Team | Assignee: | Dmitry Lukyanov (Inactive) |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | FY22Q1 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Server Compat: | 4.4, 4.9 | ||||||||
| Description |
| Comments |
| Comment by James Kovacs [ 07/Jan/21 ] | |||||||||||||||||||||||||||||||
|
As noted above, $searchScoreDetails can be supported using the existing ProjectionDefinitionBuilder<T>.Meta method. The following sample code demonstrates adding both searchHighlights and searchScoreDetails to a $search aggregation pipeline.
The following is the resulting output:
This pipeline can be executed against an Atlas cluster via collection.Aggregate(pipeline). | |||||||||||||||||||||||||||||||
| Comment by Dmitry Lukyanov (Inactive) [ 07/Jan/21 ] | |||||||||||||||||||||||||||||||
|
We don't have a typed builder for $meta, instead we allow passing just a string value: https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Driver/ProjectionDefinitionBuilder.cs#L152 Related tests: https://github.com/mongodb/mongo-csharp-driver/blob/master/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs#L140. So, we already support this feature using the generic Meta method which accepts an arbitrary string value. Therefore no driver-related work is required. |