Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSHARP-5429: Support strings with range operator for atlas search #1588

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

adelinowona
Copy link
Contributor

No description provided.

@adelinowona adelinowona requested a review from papafe January 8, 2025 19:55
@adelinowona adelinowona requested a review from a team as a code owner January 8, 2025 19:55
Copy link
Contributor

@papafe papafe left a comment

Choose a reason for hiding this comment

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

Overall it looks good! Some smaller comments

/// <param name="value">The value.</param>
/// <returns>StringSearchRange.</returns>
public static StringSearchRange Lt(this StringSearchRange stringSearchRange, string value)
=> new(stringSearchRange.Min, max: value, stringSearchRange.IsMinInclusive, false);
Copy link
Contributor

@papafe papafe Jan 9, 2025

Choose a reason for hiding this comment

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

Better add the name of the last parameter name, so it's easier to understand what's happening here.

/// <param name="value">The value.</param>
/// <returns>StringSearchRange.</returns>
public static StringSearchRange Lte(this StringSearchRange stringSearchRange, string value)
=> new(stringSearchRange.Min, max: value, stringSearchRange.IsMinInclusive, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as before

@@ -611,6 +611,33 @@ public SearchDefinition<TDocument> Range<TField>(
SearchScoreDefinition<TDocument> score = null)
where TField : struct, IComparable<TField> =>
new RangeSearchDefinition<TDocument, TField>(path, range, score);

Copy link
Contributor

Choose a reason for hiding this comment

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

You're missing a constructor that takes Expression<Func<TDocument, IEnumerable<TField>>> for path, and a relative test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already added this in another PR that was merged. I just need to rebase my current PR to show that.

Copy link
Contributor

@papafe papafe Jan 10, 2025

Choose a reason for hiding this comment

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

Maybe I'm missing something but I mean another constructor with this signature:

        public SearchDefinition<TDocument> Range<TField>(
            Expression<Func<TDocument, IEnumerable<TField>>> path,
            StringSearchRange range,
            SearchScoreDefinition<TDocument> score = null)

This is so that the constructor can be used when the field is an IEnumerable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I thought you were mentioning it for other Range methods that use SearchRange. So for the new Range overloads using StringSearchRange, we don't need another overload with IEnumerable<TField> since TField isn't used anywhere else for the parameters. So if a user uses a field that is an IEnumerable, TField would be an IEnumerable.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad! You're right, in this case we got no parameters.

Copy link
Contributor

@papafe papafe left a comment

Choose a reason for hiding this comment

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

Looks good to me, let's just maybe talk about it during next standup to be sure we all agree this should be merged now

@adelinowona adelinowona requested a review from BorisDog January 14, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants