Skip to content

CSHARP-6020: Add builders for the doesNotAffect field for in, range, equals and compound Atlas Search operators#2032

Open
sanych-sun wants to merge 4 commits into
mongodb:mainfrom
sanych-sun:CSHARP-6020
Open

CSHARP-6020: Add builders for the doesNotAffect field for in, range, equals and compound Atlas Search operators#2032
sanych-sun wants to merge 4 commits into
mongodb:mainfrom
sanych-sun:CSHARP-6020

Conversation

@sanych-sun

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 9, 2026 23:29
@sanych-sun sanych-sun requested a review from a team as a code owner June 9, 2026 23:29
@sanych-sun sanych-sun requested a review from papafe June 9, 2026 23:29
@sanych-sun sanych-sun added the feature Adds new user-facing functionality. label Jun 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for rendering Atlas Search’s doesNotAffect option across several operators so facet counts can be computed over the full result set even when certain operators are applied.

Changes:

  • Added doesNotAffect rendering for equals, in, and range operators, plus a fluent DoesNotAffect(...) builder for compound.
  • Introduced new SearchDefinitionBuilder overloads to accept doesNotAffect for Equals, In, and Range.
  • Added unit and Atlas integration tests validating doesNotAffect rendering and behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 24 comments.

Show a summary per file
File Description
tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs Adds rendering tests for doesNotAffect on compound, equals, in, and range.
tests/MongoDB.Driver.Tests/Search/AtlasSearchTests.cs Adds Atlas integration coverage for doesNotAffect with facets; introduces Movie.Year mapping.
src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs Adds public overloads for doesNotAffect; updates (and in several cases regresses) XML docs around SearchPathDefinition.
src/MongoDB.Driver/Search/OperatorSearchDefinitions.cs Implements doesNotAffect serialization for Compound, Equals, In, and Range operator definitions.
src/MongoDB.Driver/Search/CompoundSearchDefinitionBuilder.cs Adds fluent DoesNotAffect(string facetName) to the compound builder and passes it through to rendering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs Outdated
Comment thread src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs Outdated
Comment on lines +139 to +143
public SearchDefinition<TDocument> Equals<TField>(
FieldDefinition<TDocument, TField> path,
TField value,
IEnumerable<string> doesNotAffect,
SearchScoreDefinition<TDocument> score = null) =>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not agree. Even though this looks like ambiguous call, having 3rd parameter as null should resolve to the overload with SearchScoreDefinition parameter. However it does not really matter what overload will be selected - it will result in call having both score and doesNotAffect having null as a value.
We probably should consider builder pattern here for future, but it would be a breaking change - so not in scope of this PR, but might be a good idea for major release.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked the added parameter as Options struct instead. CC: @BorisDog

Comment thread src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs Outdated
Comment thread src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs Outdated
Comment thread src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs Outdated
Comment thread src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs Outdated
: base(OperatorType.Equals, path, score)
{
_value = value;
_doesNotAffect = doesNotAffect?.ToArray();
{
Ensure.IsNotNullOrEmpty(values, nameof(values));
_values = values.ToArray();
_doesNotAffect = doesNotAffect?.ToArray();
: base(OperatorType.Range, path, score)
{
_range = range;
_doesNotAffect = doesNotAffect?.ToArray();
@sanych-sun sanych-sun changed the title CSHARP-6020: Builders for the doesNotAffect field for in, range, equals and compound Atlas Search operators CSHARP-6020: Add builders for the doesNotAffect field for in, range, equals and compound Atlas Search operators Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adds new user-facing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants