-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Sharing feedback from client organization on Atlas Search using the C# driver:
For normal Finds and Aggregations, I can write idiomatic C# with a fluent builder API. I can use all the LINQ features I'm used to having on other data structures and database providers.For $search (and $searchMeta!)...I have to either # write the BSON as a string (and worry about escaping query strings properly)
- Create nested BsonDocument objects, which gets complicated and nasty very quickly. We ended up writing the helpers in this snippet (and more), which help but are still hard to read. And easy to get wrong if we mess up the structure of the object.
A normal find query, with all the type-safe "if it builds, it works" LINQ goodness:
// normal collection Find (where if it builds, it works)
collection
.Find(x => x.AnArrayField.Contains(someId))
.SortByDescending(x => x.ADateField)
.Project(x => new SomeModel(x.Id, x.Value1, x.Value2))
.ToList();
// Atlas Search stuff...where if it builds, we're still not sure it will work
// create text search operator with score boost
private BsonDocument SearchFieldWithBoost(string field, string value, int Boost)
// Add text search operator with fuzzy parameters
private BsonDocument GetTextFuzzyStage(string field, string value)
// add numeric filter
private BsonDocument GetIntEqualsStage(string field, int value)
// combine must, should, and filter arrays to build compound operator
private BsonDocument BuildCompoundStage(BsonArray should, BsonArray must, BsonArray filter)
A basic user story the user offered is, "As a developer, I would like to use a fluent API and lambda expressions to build $search/$searchMeta aggregation stages that I can be confident are correctly written*.*i.e. only uses fields that are defined in my document model and only uses operators/options that are supported by Search with no typos."
- duplicates
-
CSHARP-4440 Incorporate MongoDB.Labs.Search library
- Closed