-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Indexes dont work as expected on spring-data-mongodb 3.2.5 #3869
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
Comments
I am going to give you a bit more information on the issue. The duplicate condition caused by Map of InteractionElements. Here is the code that caused it: When spring-data-mongo 2.2.9 was processing it to get mappedKey, it uses the method |
Thanks for reporting. @brybakov1973 could you please add the structure of the involved domain types to reproduce the issue. |
{
} |
thanks - I was more thinking of the Java type that is involved in the mapping. |
public class InteractionBody {
} |
Thanks for the update. I do see the duplication of the key now when mapping the generated index against the domain type. This should not happen. We'll take care of it. I’d be interested if the index ever worked because by looking at the snippets provided the index |
You are correct, Mongo never used this kind of indexes in the search. I opened MongoDb support ticket and we concluded (together with Mongo support) that until they implement wildcard one (*) this doesn't do a thing. Mongo has this feature request already in their road map. |
Since the auto indexes were set to false by default, creating the indexes programmatically on a spring application causes indexes to be created wrong.
It seems the cause for this is a fix for spring-data-mongodb in versions 3 and up [https://github.com/spring-projects/spring-data-mongodb/commit/ab5b1f01409b301483a0692a9417522731ce40a5]
mapper.getMappedSort call leads to collection.createIndex parameter to be wrong for some of our indexes
and leads to errors like
{ v: 2, key: { interactionElements.conditions.name: 1 }, name: "interactionElements.conditions.name", has the same name as the requested index: { v: 2, key: { interactionElements.conditions.conditions.name: 1 }
Note the redundant '.conditions' in the request.
This occurs when one of the parameters is a map.
The problem is severe - we cannot trust Spring Data with programmatic indexes creation from Java.
`
private void ensureAnnotatedIndexes(MongoConnection connection, String tenantId, String environmentName) {
}`
The text was updated successfully, but these errors were encountered: