Skip to content
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
64fb0b6
MongoDB indexes support
radovanradic Mar 27, 2026
4e68aa8
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic Mar 28, 2026
dcbd91f
MongoDB indexes support
radovanradic Mar 28, 2026
c98ab84
MongoDB indexes support
radovanradic Mar 28, 2026
571a426
MongoDB indexes support
radovanradic Mar 28, 2026
d9f2668
MongoDB indexes support
radovanradic Mar 29, 2026
14b1f1f
Branch build trigger
radovanradic Mar 29, 2026
e8f735f
Support $text criteria
radovanradic Mar 29, 2026
c942288
Support $text criteria
radovanradic Mar 29, 2026
fdb19c0
MongoDB index support. Refactor package, javadocs.
radovanradic Mar 29, 2026
f04cb15
MongoDB index support. Refactor package, javadocs.
radovanradic Mar 29, 2026
03b66b9
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic Mar 30, 2026
3f308fd
Mongo indexes, some small improvements
radovanradic Mar 30, 2026
dda7d8e
Mongo indexes, some small improvements
radovanradic Mar 30, 2026
942bda9
Mongo indexes improvements
radovanradic Mar 30, 2026
eebec12
Minor improvement
radovanradic Mar 30, 2026
dbc7284
Inject converters instead of manually creating
radovanradic Mar 31, 2026
70b7f89
Minor changes and improvements
radovanradic Mar 31, 2026
31afb95
Minor changes and improvements
radovanradic Mar 31, 2026
e9e77fa
Remove unneeded code changes, leave only index related stuff.
radovanradic Apr 1, 2026
658340e
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic Apr 1, 2026
28cb063
Remove unneeded code changes, leave only index related stuff.
radovanradic Apr 1, 2026
4bfb050
Remove unneeded code changes, leave only index related stuff.
radovanradic Apr 1, 2026
a57a1ef
Cleanup tests, remove some non needed extra tests.
radovanradic Apr 1, 2026
d678d01
Cleanup tests, remove some non needed extra tests.
radovanradic Apr 1, 2026
739b5d2
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic Apr 2, 2026
752ae36
Undo formatting
radovanradic Apr 2, 2026
6755710
More index validation and some docs
radovanradic Apr 2, 2026
9d5774a
Fix top level wildcard indexes resolving
radovanradic Apr 2, 2026
e518d50
Cleanup
radovanradic Apr 2, 2026
15344eb
Cleanup
radovanradic Apr 2, 2026
46b855c
Cleanup
radovanradic Apr 2, 2026
63c6b1e
Cleanup
radovanradic Apr 2, 2026
df2d38d
Remove branch build triggers
radovanradic Apr 2, 2026
c8cd58b
Address CR comments.
radovanradic Apr 2, 2026
c2f9997
Improvements, covering some gaps noticed in peer review.
radovanradic Apr 16, 2026
00ee518
Merge remote-tracking branch 'origin/5.0.x' into radovanradic/mongodb…
radovanradic Apr 16, 2026
42a250f
Address CR comments, use condition for collection/index creation.
radovanradic Apr 16, 2026
208172f
Merge remote-tracking branch 'origin/5.1.x' into radovanradic/mongodb…
radovanradic May 29, 2026
a2c3152
Update since to 5.1.0
radovanradic May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* {@code
* @JsonView(value = "CONTACT_VIEW", alias = "cv", entity = Contact.class)
* public class ContactView {
* @Id
* @GeneratedValue(GeneratedValue.Type.IDENTITY)
* @Id
* @GeneratedValue(GeneratedValue.Type.IDENTITY)
* private Long id;
* private String name;
* private int age;
Expand Down
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;
}
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 "";
}
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;
}
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, ElementType.ANNOTATION_TYPE})
@Documented
@Inherited
public @interface MongoCompoundIndexes {

/**
* @return The indexes.
*/
MongoCompoundIndex[] value() default {};
}
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;
}
}
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;
}
Loading
Loading