Skip to content

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

Merged
Adam Sitnik (adamsitnik) merged 24 commits into
microsoft:feature-vector-data-preb2from
adamsitnik:queryAsync
Apr 9, 2025
Merged

Adam Sitnik (adamsitnik) merged 24 commits into
microsoft:feature-vector-data-preb2from
adamsitnik:queryAsync

Conversation

@adamsitnik

@adamsitnik Adam Sitnik (adamsitnik) commented Mar 21, 2025 •

Copy link
Copy Markdown
Member
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 Adam Sitnik (adamsitnik) added .NET Issue or Pull requests regarding .NET code msft.ext.vectordata Related to Microsoft.Extensions.VectorData labels Mar 21, 2025
@markwallace-microsoft Mark Wallace (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 Adam Sitnik (adamsitnik) changed the title .Net: [DRAFT] .Net MEVD: QueryAsync: initial implementation for Pinecone, Qdrant and Weaviate .Net: [DRAFT] MEVD: QueryAsync Mar 24, 2025
@adamsitnik Adam Sitnik (adamsitnik) changed the title .Net: [DRAFT] MEVD: QueryAsync .Net MEVD: QueryAsync Mar 27, 2025
@adamsitnik
Adam Sitnik (adamsitnik) marked this pull request as ready for review March 27, 2025 16:38
@adamsitnik
Adam Sitnik (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
…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

@roji Shay Rojansky (roji) left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

…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

@roji Shay Rojansky (roji) left a comment

Copy link
Copy Markdown
Member

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 Adam Sitnik (@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

This branch was previously deployed

1 inactive deployment
integration — de72aec0 Deployed Apr 9, 2025 by adamsitnik
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