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

.Net MEVD: Filter-only search API (without vector similarity) #11112

Merged
merged 24 commits into from
Apr 9, 2025

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Mar 21, 2025

GetFilteredRecordOptions<FilterRecord> options = new();

options.OrderBy
    .Ascending(r => r.Int)
    .Descending(r => r.String);

return await collection.GetAsync(record => record.Int > 2, top: 100, options).ToListAsync();

Implemented with tests for:

  • Azure AI Search
  • Pinecone
  • Qdrant
  • Weaviate
  • CosmosDB NoSQL
  • CosmosDB Mongo
  • MongoDB
  • InMemory
  • PostgreSQL
  • SQL Server
  • SQLite
  • Redis HashSet
  • Redis JSON

fixes #10295

@adamsitnik adamsitnik added .NET Issue or Pull requests regarding .NET code msft.ext.vectordata Related to Microsoft.Extensions.VectorData labels Mar 21, 2025
@markwallace-microsoft markwallace-microsoft added kernel Issues or pull requests impacting the core kernel memory labels Mar 21, 2025
@github-actions github-actions bot changed the title [DRAFT] .Net MEVD: QueryAsync: initial implementation for Pinecone, Qdrant and Weaviate .Net: [DRAFT] .Net MEVD: QueryAsync: initial implementation for Pinecone, Qdrant and Weaviate Mar 21, 2025
@adamsitnik adamsitnik changed the title .Net: [DRAFT] .Net MEVD: QueryAsync: initial implementation for Pinecone, Qdrant and Weaviate .Net: [DRAFT] MEVD: QueryAsync Mar 24, 2025
@adamsitnik adamsitnik changed the title .Net: [DRAFT] MEVD: QueryAsync .Net MEVD: QueryAsync Mar 27, 2025
@adamsitnik adamsitnik marked this pull request as ready for review March 27, 2025 16:38
@adamsitnik adamsitnik requested a review from a team as a code owner March 27, 2025 16:38
@adamsitnik

This comment was marked as outdated.

@adamsitnik

This comment was marked as resolved.

…o queryAsync

# Conflicts:
#	dotnet/src/Connectors/Connectors.Memory.Postgres/PostgresVectorStoreDbClient.cs
#	dotnet/src/Connectors/Connectors.Memory.Postgres/SqlBuilder.cs
#	dotnet/src/Connectors/Connectors.Postgres.UnitTests/PostgresVectorStoreCollectionSqlBuilderTests.cs
#	dotnet/src/VectorDataIntegrationTests/AzureAISearchIntegrationTests/Support/AzureAISearchTestStore.cs
…o queryAsync

# Conflicts:
#	dotnet/src/Connectors/VectorData/VectorStorage/LoggingVectorStoreRecordCollection.cs
Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
…o queryAsync

# Conflicts:
#	dotnet/samples/Concepts/Memory/VectorStoreEmbeddingGeneration/TextEmbeddingVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.AzureAISearch/AzureAISearchVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.AzureCosmosDBNoSQL/AzureCosmosDBNoSQLVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.MongoDB/MongoDBVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.Qdrant/QdrantVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.Weaviate/WeaviateVectorStoreRecordCollection.cs
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Awesome to see this, am really happy we'll have this capability!

{
IsFilterable = dataProperty.IsFilterable,
// Sometimes the users ask to also OrderBy given filterable property, so we make it sortable.
IsSortable = dataProperty.IsFilterable && !fieldType.IsCollection
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think this is one of the reasons we thought about renaming IsFilterable to IsIndexable indeed... In the future, we can have an Azure AI-specific IsSortable flag too.

public VectorStoreRecordPropertyModel GetDataOrKeyProperty<TRecord>(Expression<Func<TRecord, object?>> expression)
=> this.GetMatchingProperty<TRecord, VectorStoreRecordPropertyModel>(expression, data: true);

private TProperty GetMatchingProperty<TRecord, TProperty>(Expression<Func<TRecord, object?>> expression, bool data)
Copy link
Member

Choose a reason for hiding this comment

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

Just noting that this parameter is mainly there because of VectorStoreGenericDataModel, which has different dictionaries for data/vectors; that's going away with the transition to Dictionary<string, object?> tracked by #10802 (PR should be out this weekend).

In other words, I think this is super temporary and will be gone soon (so should be OK to merge as-is for now). We'd also rename GetDataOrKeyProperty to something like BindProperty (I'm already thinking about this also in relation to the filter translators...).

Comment on lines 370 to 376
foreach (var property in model.Properties)
{
if (options.IncludeVectors || property is not VectorStoreRecordVectorPropertyModel)
{
query.AppendFormat("\"{0}\",", property.StorageName);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we should definitely do some passes to consolidate/refactor.

@adamsitnik adamsitnik requested a review from roji April 7, 2025 10:36
…o queryAsync

# Conflicts:
#	dotnet/src/Connectors/Connectors.Memory.AzureCosmosDBMongoDB/AzureCosmosDBMongoDBVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.InMemory/InMemoryVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.Pinecone/PineconeVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.Postgres/PostgresVectorStoreDbClient.cs
#	dotnet/src/Connectors/Connectors.Memory.Postgres/PostgresVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.Redis/RedisHashSetVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/Connectors.Memory.Redis/RedisJsonVectorStoreRecordCollection.cs
#	dotnet/src/Connectors/VectorData.Abstractions/CompatibilitySuppressions.xml
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

OK, there seem to be a few more unresolved comments, but nothing that looks blocking - LGTM. Thanks @adamsitnik!

…o queryAsync

# Conflicts:
#	dotnet/src/Connectors/Connectors.Memory.AzureAISearch/AzureAISearchVectorStoreRecordCollection.cs
- rename FilterOptions to GetFilteredRecordOptions
- rename Sort to OrderBy
- remove the limitation to select Key as the Redis ordeby field
@adamsitnik adamsitnik merged commit 747531c into microsoft:feature-vector-data-preb2 Apr 9, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel memory msft.ext.vectordata Related to Microsoft.Extensions.VectorData .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants