-
Notifications
You must be signed in to change notification settings - Fork 227
MongoDB indexes support #3795
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
Open
radovanradic
wants to merge
40
commits into
5.1.x
Choose a base branch
from
radovanradic/mongodb-indexes
base: 5.1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
MongoDB indexes support #3795
Changes from 34 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
64fb0b6
MongoDB indexes support
radovanradic 4e68aa8
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic dcbd91f
MongoDB indexes support
radovanradic c98ab84
MongoDB indexes support
radovanradic 571a426
MongoDB indexes support
radovanradic d9f2668
MongoDB indexes support
radovanradic 14b1f1f
Branch build trigger
radovanradic e8f735f
Support $text criteria
radovanradic c942288
Support $text criteria
radovanradic fdb19c0
MongoDB index support. Refactor package, javadocs.
radovanradic f04cb15
MongoDB index support. Refactor package, javadocs.
radovanradic 03b66b9
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic 3f308fd
Mongo indexes, some small improvements
radovanradic dda7d8e
Mongo indexes, some small improvements
radovanradic 942bda9
Mongo indexes improvements
radovanradic eebec12
Minor improvement
radovanradic dbc7284
Inject converters instead of manually creating
radovanradic 70b7f89
Minor changes and improvements
radovanradic 31afb95
Minor changes and improvements
radovanradic e9e77fa
Remove unneeded code changes, leave only index related stuff.
radovanradic 658340e
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic 28cb063
Remove unneeded code changes, leave only index related stuff.
radovanradic 4bfb050
Remove unneeded code changes, leave only index related stuff.
radovanradic a57a1ef
Cleanup tests, remove some non needed extra tests.
radovanradic d678d01
Cleanup tests, remove some non needed extra tests.
radovanradic 739b5d2
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic 752ae36
Undo formatting
radovanradic 6755710
More index validation and some docs
radovanradic 9d5774a
Fix top level wildcard indexes resolving
radovanradic e518d50
Cleanup
radovanradic 15344eb
Cleanup
radovanradic 46b855c
Cleanup
radovanradic 63c6b1e
Cleanup
radovanradic df2d38d
Remove branch build triggers
radovanradic c8cd58b
Address CR comments.
radovanradic c2f9997
Improvements, covering some gaps noticed in peer review.
radovanradic 00ee518
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic 42a250f
Address CR comments, use condition for collection/index creation.
radovanradic 208172f
Merge remote-tracking branch 'origin/5.1.x' into radovanradic/mongodb…
radovanradic a2c3152
Update since to 5.1.0
radovanradic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...mongodb/src/main/java/io/micronaut/data/mongodb/annotation/index/MongoClusteredIndex.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Copyright 2017-2026 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.data.mongodb.annotation.index; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Inherited; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Declares MongoDB clustered collection options for an entity collection. | ||
| * | ||
| * @author radovanradic | ||
| * @since 5.0.0 | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE}) | ||
| @Documented | ||
| @Inherited | ||
| public @interface MongoClusteredIndex { | ||
|
|
||
| /** | ||
| * @return The clustered index name. | ||
| */ | ||
| String name() default ""; | ||
|
|
||
| /** | ||
| * @return Whether clustered index is unique. MongoDB requires {@code true}. | ||
| */ | ||
| boolean unique() default true; | ||
|
|
||
| /** | ||
| * @return The collection expiration in seconds for clustered TTL collections. | ||
| */ | ||
| int expireAfterSeconds() default -1; | ||
| } |
93 changes: 93 additions & 0 deletions
93
...-mongodb/src/main/java/io/micronaut/data/mongodb/annotation/index/MongoCompoundIndex.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright 2017-2026 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.data.mongodb.annotation.index; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Inherited; | ||
| import java.lang.annotation.Repeatable; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Declares a compound MongoDB index for an entity. | ||
| * | ||
| * @author radovanradic | ||
| * @since 5.0.0 | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE}) | ||
| @Documented | ||
| @Inherited | ||
| @Repeatable(MongoCompoundIndexes.class) | ||
| public @interface MongoCompoundIndex { | ||
|
|
||
| /** | ||
| * @return The index name. | ||
| */ | ||
| String name() default ""; | ||
|
|
||
| /** | ||
| * @return The fields. | ||
| */ | ||
| MongoCompoundIndexField[] fields(); | ||
|
|
||
| /** | ||
| * @return Whether the index is unique. | ||
| */ | ||
| boolean unique() default false; | ||
|
|
||
| /** | ||
| * @return Whether the index is sparse. | ||
| */ | ||
| boolean sparse() default false; | ||
|
|
||
| /** | ||
| * @return Whether the index is hidden. | ||
| */ | ||
| boolean hidden() default false; | ||
|
|
||
| /** | ||
| * @return The index expiration in seconds. | ||
| */ | ||
| int expireAfterSeconds() default -1; | ||
|
|
||
| /** | ||
| * @return The partial filter expression as JSON. | ||
| */ | ||
| String partialFilterExpression() default ""; | ||
|
|
||
| /** | ||
| * @return The collation definition as JSON. | ||
| */ | ||
| String collation() default ""; | ||
|
|
||
| /** | ||
| * @return The index creation command comment. | ||
| */ | ||
| String comment() default ""; | ||
|
|
||
| /** | ||
| * @return The createIndexes commit quorum. | ||
| */ | ||
| String commitQuorum() default ""; | ||
|
|
||
| /** | ||
| * @return The storage engine options as JSON. | ||
| */ | ||
| String storageEngine() default ""; | ||
| } |
66 changes: 66 additions & 0 deletions
66
...odb/src/main/java/io/micronaut/data/mongodb/annotation/index/MongoCompoundIndexField.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Copyright 2017-2026 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.data.mongodb.annotation.index; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
|
|
||
| /** | ||
| * Declares a field within a compound MongoDB index. | ||
| * | ||
| * @author radovanradic | ||
| * @since 5.0.0 | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Documented | ||
| public @interface MongoCompoundIndexField { | ||
|
|
||
| /** | ||
| * @return The property path. | ||
| */ | ||
| String value(); | ||
|
|
||
| /** | ||
| * @return The field direction. | ||
| */ | ||
| MongoIndexDirection direction() default MongoIndexDirection.ASC; | ||
|
|
||
| /** | ||
| * @return The geospatial key kind when this field should use a geospatial index key inside a compound index. | ||
| */ | ||
| MongoGeoIndexType geoType() default MongoGeoIndexType.GEO_2DSPHERE; | ||
|
|
||
| /** | ||
| * @return Whether the field should use the geospatial key kind instead of the numeric direction. | ||
| */ | ||
| boolean geo() default false; | ||
|
|
||
| /** | ||
| * @return The 2d index bits setting, or -1 if unset. | ||
| */ | ||
| int bits() default -1; | ||
|
|
||
| /** | ||
| * @return The 2d index minimum value, or NaN if unset. | ||
| */ | ||
| double min() default Double.NaN; | ||
|
|
||
| /** | ||
| * @return The 2d index maximum value, or NaN if unset. | ||
| */ | ||
| double max() default Double.NaN; | ||
| } |
41 changes: 41 additions & 0 deletions
41
...ongodb/src/main/java/io/micronaut/data/mongodb/annotation/index/MongoCompoundIndexes.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright 2017-2026 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.data.mongodb.annotation.index; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Inherited; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Repeatable annotation for {@link MongoCompoundIndex}. | ||
| * | ||
| * @author radovanradic | ||
| * @since 5.0.0 | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target(ElementType.TYPE) | ||
| @Documented | ||
| @Inherited | ||
| public @interface MongoCompoundIndexes { | ||
|
|
||
| /** | ||
| * @return The indexes. | ||
| */ | ||
| MongoCompoundIndex[] value() default {}; | ||
| } | ||
40 changes: 40 additions & 0 deletions
40
data-mongodb/src/main/java/io/micronaut/data/mongodb/annotation/index/MongoGeoIndexType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Copyright 2017-2026 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.data.mongodb.annotation.index; | ||
|
|
||
| /** | ||
| * Supported MongoDB geospatial index kinds. | ||
| * | ||
| * @author radovanradic | ||
| * @since 5.0.0 | ||
| */ | ||
| public enum MongoGeoIndexType { | ||
| GEO_2D("2d"), | ||
| GEO_2DSPHERE("2dsphere"); | ||
|
|
||
| private final String key; | ||
|
|
||
| MongoGeoIndexType(String key) { | ||
| this.key = key; | ||
| } | ||
|
|
||
| /** | ||
| * @return The MongoDB key value. | ||
| */ | ||
| public String getKey() { | ||
| return key; | ||
| } | ||
| } |
85 changes: 85 additions & 0 deletions
85
data-mongodb/src/main/java/io/micronaut/data/mongodb/annotation/index/MongoGeoIndexed.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Copyright 2017-2026 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.data.mongodb.annotation.index; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Inherited; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Declares a simple MongoDB geospatial index for a property. | ||
| * | ||
| * @author radovanradic | ||
| * @since 5.0.0 | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE}) | ||
| @Documented | ||
| @Inherited | ||
| public @interface MongoGeoIndexed { | ||
|
|
||
| /** | ||
| * @return The index name. | ||
| */ | ||
| String name() default ""; | ||
|
|
||
| /** | ||
| * @return The geospatial index kind. Defaults to {@link MongoGeoIndexType#GEO_2DSPHERE}. | ||
| */ | ||
| MongoGeoIndexType type() default MongoGeoIndexType.GEO_2DSPHERE; | ||
|
|
||
| /** | ||
| * @return Whether the index is hidden. | ||
| */ | ||
| boolean hidden() default false; | ||
|
|
||
| /** | ||
| * @return The index creation command comment. | ||
| */ | ||
| String comment() default ""; | ||
|
|
||
| /** | ||
| * @return The storage engine options as JSON. | ||
| */ | ||
| String storageEngine() default ""; | ||
|
|
||
| /** | ||
| * @return The 2dsphere index version, or {@code -1} if unset. Only valid for | ||
| * {@link MongoGeoIndexType#GEO_2DSPHERE}. | ||
| */ | ||
| int sphereVersion() default -1; | ||
|
|
||
| /** | ||
| * @return The 2d index bits setting, or {@code -1} if unset. Only valid for | ||
| * {@link MongoGeoIndexType#GEO_2D}. Valid range is 1..32 inclusive. MongoDB default is 26. | ||
| */ | ||
| int bits() default -1; | ||
|
|
||
| /** | ||
| * @return The 2d index minimum value, or {@link Double#NaN} if unset. Only valid for | ||
| * {@link MongoGeoIndexType#GEO_2D}. Represents the lower inclusive boundary. MongoDB default is -180.0. | ||
| */ | ||
| double min() default Double.NaN; | ||
|
|
||
| /** | ||
| * @return The 2d index maximum value, or {@link Double#NaN} if unset. Only valid for | ||
| * {@link MongoGeoIndexType#GEO_2D}. Represents the upper inclusive boundary. MongoDB default is 180.0. | ||
| */ | ||
| double max() default Double.NaN; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.