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

The Cosmos provider ignores configured indexes #34023

Closed
ajcvickers opened this issue Jun 18, 2024 · 4 comments · Fixed by #34054
Closed

The Cosmos provider ignores configured indexes #34023

ajcvickers opened this issue Jun 18, 2024 · 4 comments · Fixed by #34054
Labels
area-cosmos breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug

Comments

@ajcvickers
Copy link
Member

For example:

modelBuilder.Entity<Book>().HasIndex(e => e.ByteArray);

This will currently pass model validation, but the index is ignored. We should fail for this in model validation.

@roji
Copy link
Member

roji commented Jun 18, 2024

Or implement it ;)

@ajcvickers
Copy link
Member Author

Or implement it ;)

I could be wrong, but I don't think a naked .HasIndex call will ever do anything on Cosmos. You're going to need to chain something (like ForVectors) to specify how it will be used in the index specification.

@roji
Copy link
Member

roji commented Jun 19, 2024

This definitely would require more thinking... You know more than me, but it seems like it could make sense to apply a Cosmos indexing policy that includes paths only to the properties on which HasIndex() has been called, no? One big difference from relational is that in relational, there are no indexes by default, whereas in Cosmos everything seems to be indexed by default, and the policy is more of a way to do finer-grained tweaking to only index specific properties.

In any case, probably not for 9.0, so yeah, validating against HasIndex() at this point sounds like the right thing indeed...

@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 21, 2024
@ajcvickers ajcvickers added this to the 9.0.0 milestone Jun 21, 2024
ajcvickers added a commit that referenced this issue Jun 21, 2024
Block unused indexes with the Cosmos provider. Fixes #34023.

Also stop adding indexes for foreign keys by convention for relational providers. Fixes #34053.
ajcvickers added a commit that referenced this issue Jul 2, 2024
Block unused indexes with the Cosmos provider. Fixes #34023.

Also stop adding indexes for foreign keys by convention for relational providers. Fixes #34053.
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview7 Jul 8, 2024
@ajcvickers ajcvickers removed their assignment Aug 31, 2024
@roji
Copy link
Member

roji commented Sep 22, 2024

See #32517 for enabling proper support for HasIndex() on Cosmos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants