Skip to content

Conversation

leminh98
Copy link
Contributor

@leminh98 leminh98 commented May 1, 2025

Pull Request Template

Description

This PR adds LINQ extension method for VectorDistance. There are 3 interface corresponding to the 3 different type supported for VectorDistance. Usage example:

var distance = documents.Select(document => document.vector1.VectorDistance(<vector2>, true, {'distanceFunction':'cosine', 'dataType':'float32'}));

Refer to the unit test for more examples.

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

@leminh98 leminh98 added the auto-merge Enables automation to merge PRs label May 1, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot enabled auto-merge (squash) May 1, 2025 10:19
@leminh98 leminh98 requested a review from Pilchie as a code owner May 8, 2025 18:05
sboshra
sboshra previously approved these changes May 9, 2025
Copy link
Contributor

@sboshra sboshra left a comment

Choose a reason for hiding this comment

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

:shipit:


if (methodCallExpression.Arguments[3] is ConstantExpression optionExpression && optionExpression.Value != null)
{
string serializedConstant = System.Text.Json.JsonSerializer.Serialize(
Copy link
Contributor

@adityasa adityasa May 9, 2025

Choose a reason for hiding this comment

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

System.Text.Json

Nit, full qualification not required. #Resolved

/// <summary>
/// Represents default value.
/// </summary>
None,
Copy link
Contributor

@adityasa adityasa May 9, 2025

Choose a reason for hiding this comment

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

I am not sure other consumers of this class would work ok with this value. #Pending

Copy link
Contributor

Choose a reason for hiding this comment

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

If we need, we can create a copy of this enum in CosmosLinqExtensions class/namespace.

/// <summary>
/// Represents default value.
/// </summary>
None,
Copy link
Contributor

@adityasa adityasa May 9, 2025

Choose a reason for hiding this comment

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

None

I am not sure other consumers of this class would work ok with this value. #Pending

@adityasa adityasa dismissed stale reviews from kirankumarkolli and sboshra via 7ea77cb May 14, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Enables automation to merge PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants