Skip to content

[MEVD] Throwing instead of automatically choosing the first property in the schema when one isn't specified by the user #10423

Closed

Description

@roji

When a collection has multiple vector properties, users can select which one they want to search over via VectorSearchOptions. Currently, if the user doesn't select one, the first vector property defined in the schema definition is automatically selected.

The fact that the schema property order affects this is quite non-obvious when using the API: the schema definition is provided in a completely different place (startup) vs. the place where the search is taking place. The situation seems even worse when the schema definition is inferred from the CLR type (via the attributes): I suspect the order then depends on reflection order, which would mean that if a user moves properties around in their C# code, their search suddenly starts to return no results!

In other words, I suspect lots of users will fall into a pit of failure here, where they simply don't get the expected result because the wrong vector property gets silently selected for them.

Instead, I'd propose we simply throw if there are multiple candidate properties and the user hasn't explicitly selected one. The main problem here seems to be the breaking change with regards to the current behavior. I'd argue that this is quite a benign breaking change: although it's a runtime break (rather than compile-time), it's very fail-fast (any code doing search fails immediately), and our exception can very explicitly guide the user towards the mitigation ("please set the property name explicitly").

Note also that this would only affect people with multiple vector properties - if there's only a single vector property, users wouldn't be required to specify the property. I suspect this would greatly reduce the number of users affected by this change.

Note: the same problem exists in hybrid search with selecting the full-text property (and later, the sparse vector one). Whatever we decide above should probably be applied here as well.

Activity

  1. added
    sk team issueA tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
    on Feb 6, 2025
  2. moved this from Sprint: Planned to Sprint: In Review in Semantic Kernelon Mar 5, 2025
  3. moved this from Sprint: In Review to Sprint: Done in Semantic Kernelon Mar 10, 2025
  4. changed the title [-].Net MEVD: consider throwing instead of automatically choosing the first property in the schema when one isn't specified by the user[/-] [+][MEVD] Throwing instead of automatically choosing the first property in the schema when one isn't specified by the user[/+] on Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferencememorymemory connectormsft.ext.vectordataRelated to Microsoft.Extensions.VectorDatask team issueA tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions