-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Annotation CompoundIndexes not creating indexes #434
Comments
@killesk .. currently i do not work myself with mongodb .. but i think spring should create this index.. maybe this blogposts has an hint: https://www.baeldung.com/spring-data-mongodb-index-annotations-converter |
Hi Michael, Spring creates this index when running against a "real" mongodb, but does not when using this embedded mongo lib. |
@killesk .. hmm.. this is interesting.. (to be sure: i start a real mongodb.. its not a mock, fake, or some in memory magic.. ) |
@killesk there is an autoIndexCreation property in MongoProperties .. are you sure that this is not set in production? (org.springframework.boot.autoconfigure.mongo.MongoProperties#autoIndexCreation called from here: org.springframework.boot.autoconfigure.data.mongo.MongoDataConfiguration#mongoMappingContext) |
@killesk is this still an issue? |
@killesk .. i close this issue.. just reopen, if this still is an problem. |
@michaelmosmann I'm still experiencing the same issue:
I'm using: Programmatically creating the index from within the test works. |
@serbanpop i guess you do not have a public repo with some sample code? I will see if i can recreate this issue somehow. |
@michaelmosmann Unfortunately, it's proprietary code, but I can share the setup for starting the embedded Mongo - I hope this helps.
Within the tests, the configs rely on a pre-running static process:
|
@serbanpop so you dont use the spring integration? I am not sure which part of spring data handles the index creation, but I would guess that I could make a difference.. I will see. |
@michaelmosmann I'm not starting the Embedded Mongo using |
@serbanpop i will see if i can find a way to deal with that.. |
@serbanpop can you create a new issue for that or should we reopen this one? |
@michaelmosmann can we reopen this one to avoid duplicates, please? |
When I declare a class and set some compound indexs like so:
`
@document("positionPoints")
@CompoundIndexes(
CompoundIndex(name = "optimizingType_point", def = "{'optimizingType': 1, 'point': 1}"),
CompoundIndex(name = "optimizingType_routeId_position", def = "{'optimizingType': 1, 'routeId': 1, 'position': 1}"))
class PositionPoint {
The CompoundIndexes don't appear to be created.
I get the following error
com.mongodb.MongoCommandException: Command failed with error 27 (IndexNotFound): '$geoNear requires a 2d or 2dsphere index, but none were found' on server localhost:35543. The full response is {"ok": 0.0, "errmsg": "$geoNear requires a 2d or 2dsphere index, but none were found", "code": 27, "codeName": "IndexNotFound"}
I'm using
spring-boot-starter-parent == 2.7.5
de.flapdoodle.embed.mongo == 3.5.3
spring.mongodb.embedded.version == 6.0.2
Any suggestions on how to have my compound index created automatically?
The text was updated successfully, but these errors were encountered: