Compare commits
4 Commits
issue/arch
...
issue/DATA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5f35a3972 | ||
|
|
4b2bc52ffc | ||
|
|
e6d47ce5b5 | ||
|
|
3532c1feae |
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.1.0-SNAPSHOT</version>
|
<version>3.1.0-DATAMONGO-1569-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Spring Data MongoDB</name>
|
<name>Spring Data MongoDB</name>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.1.0-SNAPSHOT</version>
|
<version>3.1.0-DATAMONGO-1569-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.1.0-SNAPSHOT</version>
|
<version>3.1.0-DATAMONGO-1569-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.1.0-SNAPSHOT</version>
|
<version>3.1.0-DATAMONGO-1569-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import java.lang.annotation.Target;
|
|||||||
* @author Philipp Schneider
|
* @author Philipp Schneider
|
||||||
* @author Johno Crawford
|
* @author Johno Crawford
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
|
* @author Dave Perryman
|
||||||
*/
|
*/
|
||||||
@Target({ ElementType.TYPE })
|
@Target({ ElementType.TYPE })
|
||||||
@Documented
|
@Documented
|
||||||
@@ -95,7 +96,8 @@ public @interface CompoundIndex {
|
|||||||
boolean unique() default false;
|
boolean unique() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to true index will skip over any document that is missing the indexed field.
|
* If set to true index will skip over any document that is missing the indexed field. <br />
|
||||||
|
* Must not be used with {@link #partialFilter()}.
|
||||||
*
|
*
|
||||||
* @return {@literal false} by default.
|
* @return {@literal false} by default.
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
@@ -170,4 +172,14 @@ public @interface CompoundIndex {
|
|||||||
*/
|
*/
|
||||||
boolean background() default false;
|
boolean background() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only index the documents in a collection that meet a specified {@link IndexFilter filter expression}. <br />
|
||||||
|
* Must not be used with {@link #sparse() sparse = true}.
|
||||||
|
*
|
||||||
|
* @return empty by default.
|
||||||
|
* @see <a href=
|
||||||
|
* "https://docs.mongodb.com/manual/core/index-partial/">https://docs.mongodb.com/manual/core/index-partial/</a>
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
String partialFilter() default "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ public @interface Indexed {
|
|||||||
IndexDirection direction() default IndexDirection.ASCENDING;
|
IndexDirection direction() default IndexDirection.ASCENDING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to true index will skip over any document that is missing the indexed field.
|
* If set to true index will skip over any document that is missing the indexed field. <br />
|
||||||
|
* Must not be used with {@link #partialFilter()}.
|
||||||
*
|
*
|
||||||
* @return {@literal false} by default.
|
* @return {@literal false} by default.
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
@@ -170,4 +171,15 @@ public @interface Indexed {
|
|||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
String expireAfter() default "";
|
String expireAfter() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only index the documents in a collection that meet a specified {@link IndexFilter filter expression}. <br />
|
||||||
|
* Must not be used with {@link #sparse() sparse = true}.
|
||||||
|
*
|
||||||
|
* @return empty by default.
|
||||||
|
* @see <a href=
|
||||||
|
* "https://docs.mongodb.com/manual/core/index-partial/">https://docs.mongodb.com/manual/core/index-partial/</a>
|
||||||
|
* @since 3.1
|
||||||
|
*/
|
||||||
|
String partialFilter() default "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity;
|
|||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||||
|
import org.springframework.data.mongodb.util.BsonUtils;
|
||||||
import org.springframework.data.spel.EvaluationContextProvider;
|
import org.springframework.data.spel.EvaluationContextProvider;
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.expression.EvaluationContext;
|
import org.springframework.expression.EvaluationContext;
|
||||||
@@ -69,6 +70,7 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Thomas Darimont
|
* @author Thomas Darimont
|
||||||
* @author Martin Macko
|
* @author Martin Macko
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
* @author Dave Perryman
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public class MongoPersistentEntityIndexResolver implements IndexResolver {
|
public class MongoPersistentEntityIndexResolver implements IndexResolver {
|
||||||
@@ -380,6 +382,10 @@ public class MongoPersistentEntityIndexResolver implements IndexResolver {
|
|||||||
indexDefinition.background();
|
indexDefinition.background();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StringUtils.hasText(index.partialFilter())) {
|
||||||
|
indexDefinition.partial(evaluatePartialFilter(index.partialFilter(), entity));
|
||||||
|
}
|
||||||
|
|
||||||
return new IndexDefinitionHolder(dotPath, indexDefinition, collection);
|
return new IndexDefinitionHolder(dotPath, indexDefinition, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,9 +475,25 @@ public class MongoPersistentEntityIndexResolver implements IndexResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StringUtils.hasText(index.partialFilter())) {
|
||||||
|
indexDefinition.partial(evaluatePartialFilter(index.partialFilter(), persistentProperty.getOwner()));
|
||||||
|
}
|
||||||
|
|
||||||
return new IndexDefinitionHolder(dotPath, indexDefinition, collection);
|
return new IndexDefinitionHolder(dotPath, indexDefinition, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PartialIndexFilter evaluatePartialFilter(String filterExpression, PersistentEntity<?,?> entity) {
|
||||||
|
|
||||||
|
Object result = evaluate(filterExpression, getEvaluationContextForProperty(entity));
|
||||||
|
|
||||||
|
if (result instanceof org.bson.Document) {
|
||||||
|
return PartialIndexFilter.of((org.bson.Document) result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PartialIndexFilter.of(BsonUtils.parse(filterExpression, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link HashedIndex} wrapped in {@link IndexDefinitionHolder} out of {@link HashIndexed} for a given
|
* Creates {@link HashedIndex} wrapped in {@link IndexDefinitionHolder} out of {@link HashIndexed} for a given
|
||||||
* {@link MongoPersistentProperty}.
|
* {@link MongoPersistentProperty}.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.lang.annotation.Target;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
import org.junit.runners.Suite.SuiteClasses;
|
import org.junit.runners.Suite.SuiteClasses;
|
||||||
@@ -54,6 +54,7 @@ import org.springframework.data.util.ClassTypeInformation;
|
|||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
* @author Dave Perryman
|
||||||
*/
|
*/
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@SuiteClasses({ IndexResolutionTests.class, GeoSpatialIndexResolutionTests.class, CompoundIndexResolutionTests.class,
|
@SuiteClasses({ IndexResolutionTests.class, GeoSpatialIndexResolutionTests.class, CompoundIndexResolutionTests.class,
|
||||||
@@ -270,23 +271,33 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
assertThat(indexDefinitions.get(0).getIndexOptions()).containsEntry("name", "my1st");
|
assertThat(indexDefinitions.get(0).getIndexOptions()).containsEntry("name", "my1st");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // DATAMONGO-1569
|
||||||
|
public void resolvesPartialFilter() {
|
||||||
|
|
||||||
|
List<IndexDefinitionHolder> indexDefinitions = prepareMappingContextAndResolveIndexForType(
|
||||||
|
WithPartialFilter.class);
|
||||||
|
|
||||||
|
assertThat(indexDefinitions.get(0).getIndexOptions()).containsEntry("partialFilterExpression",
|
||||||
|
org.bson.Document.parse("{'value': {'$exists': true}}"));
|
||||||
|
}
|
||||||
|
|
||||||
@Document("Zero")
|
@Document("Zero")
|
||||||
static class IndexOnLevelZero {
|
class IndexOnLevelZero {
|
||||||
@Indexed String indexedProperty;
|
@Indexed String indexedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("One")
|
@Document("One")
|
||||||
static class IndexOnLevelOne {
|
class IndexOnLevelOne {
|
||||||
IndexOnLevelZero zero;
|
IndexOnLevelZero zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("Two")
|
@Document("Two")
|
||||||
static class IndexOnLevelTwo {
|
class IndexOnLevelTwo {
|
||||||
IndexOnLevelOne one;
|
IndexOnLevelOne one;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("WithOptionsOnIndexedProperty")
|
@Document("WithOptionsOnIndexedProperty")
|
||||||
static class WithOptionsOnIndexedProperty {
|
class WithOptionsOnIndexedProperty {
|
||||||
|
|
||||||
@Indexed(background = true, direction = IndexDirection.DESCENDING, dropDups = true, expireAfterSeconds = 10,
|
@Indexed(background = true, direction = IndexDirection.DESCENDING, dropDups = true, expireAfterSeconds = 10,
|
||||||
sparse = true, unique = true) //
|
sparse = true, unique = true) //
|
||||||
@@ -294,23 +305,23 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class IndexOnLevelOneWithExplicitlyNamedField {
|
class IndexOnLevelOneWithExplicitlyNamedField {
|
||||||
|
|
||||||
@Field("customZero") IndexOnLevelZeroWithExplicityNamedField zero;
|
@Field("customZero") IndexOnLevelZeroWithExplicityNamedField zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class IndexOnLevelZeroWithExplicityNamedField {
|
class IndexOnLevelZeroWithExplicityNamedField {
|
||||||
|
|
||||||
@Indexed @Field("customFieldName") String namedProperty;
|
@Indexed @Field("customFieldName") String namedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WrapperOfWithDbRef {
|
class WrapperOfWithDbRef {
|
||||||
WithDbRef nested;
|
WithDbRef nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithDbRef {
|
class WithDbRef {
|
||||||
|
|
||||||
@Indexed //
|
@Indexed //
|
||||||
@DBRef //
|
@DBRef //
|
||||||
@@ -318,12 +329,12 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document("no-index")
|
@Document("no-index")
|
||||||
static class NoIndex {
|
class NoIndex {
|
||||||
@Id String id;
|
@Id String id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class IndexedDocumentWithComposedAnnotations {
|
class IndexedDocumentWithComposedAnnotations {
|
||||||
|
|
||||||
@Id String id;
|
@Id String id;
|
||||||
@CustomIndexedAnnotation String fieldWithDifferentIndexName;
|
@CustomIndexedAnnotation String fieldWithDifferentIndexName;
|
||||||
@@ -361,7 +372,7 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithExpireAfterAsPlainString {
|
class WithExpireAfterAsPlainString {
|
||||||
@Indexed(expireAfter = "10m") String withTimeout;
|
@Indexed(expireAfter = "10m") String withTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,12 +382,12 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithExpireAfterAsExpression {
|
class WithExpireAfterAsExpression {
|
||||||
@Indexed(expireAfter = "#{10 + 1 + 's'}") String withTimeout;
|
@Indexed(expireAfter = "#{10 + 1 + 's'}") String withTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithExpireAfterAsExpressionResultingInDuration {
|
class WithExpireAfterAsExpressionResultingInDuration {
|
||||||
@Indexed(expireAfter = "#{T(java.time.Duration).ofSeconds(100)}") String withTimeout;
|
@Indexed(expireAfter = "#{T(java.time.Duration).ofSeconds(100)}") String withTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,9 +402,14 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithIndexNameAsExpression {
|
class WithIndexNameAsExpression {
|
||||||
@Indexed(name = "#{'my' + 1 + 'st'}") String spelIndexName;
|
@Indexed(name = "#{'my' + 1 + 'st'}") String spelIndexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Document
|
||||||
|
class WithPartialFilter {
|
||||||
|
@Indexed(partialFilter = "{'value': {'$exists': true}}") String withPartialFilter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Target({ ElementType.FIELD })
|
@Target({ ElementType.FIELD })
|
||||||
@@ -403,7 +419,7 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class IndexOnMetaAnnotatedField {
|
class IndexOnMetaAnnotatedField {
|
||||||
@Field("_name") @IndexedFieldAnnotation String lastname;
|
@Field("_name") @IndexedFieldAnnotation String lastname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,29 +496,29 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document("Zero")
|
@Document("Zero")
|
||||||
static class GeoSpatialIndexOnLevelZero {
|
class GeoSpatialIndexOnLevelZero {
|
||||||
@GeoSpatialIndexed Point geoIndexedProperty;
|
@GeoSpatialIndexed Point geoIndexedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("One")
|
@Document("One")
|
||||||
static class GeoSpatialIndexOnLevelOne {
|
class GeoSpatialIndexOnLevelOne {
|
||||||
GeoSpatialIndexOnLevelZero zero;
|
GeoSpatialIndexOnLevelZero zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("Two")
|
@Document("Two")
|
||||||
static class GeoSpatialIndexOnLevelTwo {
|
class GeoSpatialIndexOnLevelTwo {
|
||||||
GeoSpatialIndexOnLevelOne one;
|
GeoSpatialIndexOnLevelOne one;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("WithOptionsOnGeoSpatialIndexProperty")
|
@Document("WithOptionsOnGeoSpatialIndexProperty")
|
||||||
static class WithOptionsOnGeoSpatialIndexProperty {
|
class WithOptionsOnGeoSpatialIndexProperty {
|
||||||
|
|
||||||
@GeoSpatialIndexed(bits = 2, max = 100, min = 1, type = GeoSpatialIndexType.GEO_2D) //
|
@GeoSpatialIndexed(bits = 2, max = 100, min = 1, type = GeoSpatialIndexType.GEO_2D) //
|
||||||
Point location;
|
Point location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("WithComposedAnnotation")
|
@Document("WithComposedAnnotation")
|
||||||
static class GeoSpatialIndexedDocumentWithComposedAnnotation {
|
class GeoSpatialIndexedDocumentWithComposedAnnotation {
|
||||||
|
|
||||||
@ComposedGeoSpatialIndexed //
|
@ComposedGeoSpatialIndexed //
|
||||||
Point location;
|
Point location;
|
||||||
@@ -527,7 +543,7 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class GeoIndexWithNameAsExpression {
|
class GeoIndexWithNameAsExpression {
|
||||||
@GeoSpatialIndexed(name = "#{'my' + 1 + 'st'}") Point spelIndexName;
|
@GeoSpatialIndexed(name = "#{'my' + 1 + 'st'}") Point spelIndexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,14 +679,28 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
indexDefinitions.get(1));
|
indexDefinitions.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // DATAMONGO-1569
|
||||||
|
public void singleIndexWithPartialFilter() {
|
||||||
|
|
||||||
|
List<IndexDefinitionHolder> indexDefinitions = prepareMappingContextAndResolveIndexForType(
|
||||||
|
SingleCompoundIndexWithPartialFilter.class);
|
||||||
|
|
||||||
|
assertThat(indexDefinitions).hasSize(1);
|
||||||
|
assertThat(indexDefinitions.get(0).getIndexKeys()).containsEntry("foo", 1).containsEntry("bar", -1);
|
||||||
|
assertThat(indexDefinitions.get(0).getIndexOptions()).containsEntry("name", "compound_index_with_partial")
|
||||||
|
.containsEntry("unique", true).containsEntry("background", true);
|
||||||
|
assertThat(indexDefinitions.get(0).getIndexOptions()).containsEntry("partialFilterExpression",
|
||||||
|
org.bson.Document.parse("{'value': {'$exists': true}}"));
|
||||||
|
}
|
||||||
|
|
||||||
@Document("CompoundIndexOnLevelOne")
|
@Document("CompoundIndexOnLevelOne")
|
||||||
static class CompoundIndexOnLevelOne {
|
class CompoundIndexOnLevelOne {
|
||||||
|
|
||||||
CompoundIndexOnLevelZero zero;
|
CompoundIndexOnLevelZero zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("CompoundIndexOnLevelZeroWithEmptyIndexDef")
|
@Document("CompoundIndexOnLevelZeroWithEmptyIndexDef")
|
||||||
static class CompoundIndexOnLevelOneWithEmptyIndexDefinition {
|
class CompoundIndexOnLevelOneWithEmptyIndexDefinition {
|
||||||
|
|
||||||
CompoundIndexOnLevelZeroWithEmptyIndexDef zero;
|
CompoundIndexOnLevelZeroWithEmptyIndexDef zero;
|
||||||
}
|
}
|
||||||
@@ -678,26 +708,26 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
@Document("CompoundIndexOnLevelZero")
|
@Document("CompoundIndexOnLevelZero")
|
||||||
@CompoundIndexes({ @CompoundIndex(name = "compound_index", def = "{'foo': 1, 'bar': -1}", background = true,
|
@CompoundIndexes({ @CompoundIndex(name = "compound_index", def = "{'foo': 1, 'bar': -1}", background = true,
|
||||||
sparse = true, unique = true) })
|
sparse = true, unique = true) })
|
||||||
static class CompoundIndexOnLevelZero {}
|
class CompoundIndexOnLevelZero {}
|
||||||
|
|
||||||
@CompoundIndexes({ @CompoundIndex(name = "compound_index", background = true, sparse = true, unique = true) })
|
@CompoundIndexes({ @CompoundIndex(name = "compound_index", background = true, sparse = true, unique = true) })
|
||||||
static class CompoundIndexOnLevelZeroWithEmptyIndexDef {}
|
class CompoundIndexOnLevelZeroWithEmptyIndexDef {}
|
||||||
|
|
||||||
@Document("CompoundIndexOnLevelZero")
|
@Document("CompoundIndexOnLevelZero")
|
||||||
@CompoundIndex(name = "compound_index", def = "{'foo': 1, 'bar': -1}", background = true, sparse = true,
|
@CompoundIndex(name = "compound_index", def = "{'foo': 1, 'bar': -1}", background = true, sparse = true,
|
||||||
unique = true)
|
unique = true)
|
||||||
static class SingleCompoundIndex {}
|
class SingleCompoundIndex {}
|
||||||
|
|
||||||
static class IndexDefinedOnSuperClass extends CompoundIndexOnLevelZero {}
|
class IndexDefinedOnSuperClass extends CompoundIndexOnLevelZero {}
|
||||||
|
|
||||||
@Document("ComountIndexWithAutogeneratedName")
|
@Document("ComountIndexWithAutogeneratedName")
|
||||||
@CompoundIndexes({ @CompoundIndex(useGeneratedName = true, def = "{'foo': 1, 'bar': -1}", background = true,
|
@CompoundIndexes({ @CompoundIndex(useGeneratedName = true, def = "{'foo': 1, 'bar': -1}", background = true,
|
||||||
sparse = true, unique = true) })
|
sparse = true, unique = true) })
|
||||||
static class ComountIndexWithAutogeneratedName {}
|
class ComountIndexWithAutogeneratedName {}
|
||||||
|
|
||||||
@Document("WithComposedAnnotation")
|
@Document("WithComposedAnnotation")
|
||||||
@ComposedCompoundIndex
|
@ComposedCompoundIndex
|
||||||
static class CompoundIndexDocumentWithComposedAnnotation {}
|
class CompoundIndexDocumentWithComposedAnnotation {}
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ ElementType.TYPE })
|
@Target({ ElementType.TYPE })
|
||||||
@@ -723,16 +753,21 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
|
|
||||||
@Document
|
@Document
|
||||||
@CompoundIndex(name = "#{'cmp' + 2 + 'name'}", def = "{'foo': 1, 'bar': -1}")
|
@CompoundIndex(name = "#{'cmp' + 2 + 'name'}", def = "{'foo': 1, 'bar': -1}")
|
||||||
static class CompoundIndexWithNameExpression {}
|
class CompoundIndexWithNameExpression {}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
@CompoundIndex(def = "#{T(org.bson.Document).parse(\"{ 'foo': 1, 'bar': -1 }\")}")
|
@CompoundIndex(def = "#{T(org.bson.Document).parse(\"{ 'foo': 1, 'bar': -1 }\")}")
|
||||||
static class CompoundIndexWithDefExpression {}
|
class CompoundIndexWithDefExpression {}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
@CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}")
|
@CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}")
|
||||||
@CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}")
|
@CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}")
|
||||||
static class RepeatedCompoundIndex {}
|
class RepeatedCompoundIndex {}
|
||||||
|
|
||||||
|
@Document("SingleCompoundIndexWithPartialFilter")
|
||||||
|
@CompoundIndex(name = "compound_index_with_partial", def = "{'foo': 1, 'bar': -1}", background = true,
|
||||||
|
unique = true, partialFilter = "{'value': {'$exists': true}}")
|
||||||
|
class SingleCompoundIndexWithPartialFilter {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TextIndexedResolutionTests {
|
public static class TextIndexedResolutionTests {
|
||||||
@@ -868,7 +903,7 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class TextIndexOnSinglePropertyInRoot {
|
class TextIndexOnSinglePropertyInRoot {
|
||||||
|
|
||||||
String foo;
|
String foo;
|
||||||
|
|
||||||
@@ -876,13 +911,13 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document(collation = "de_AT")
|
@Document(collation = "de_AT")
|
||||||
static class TextIndexWithCollation {
|
class TextIndexWithCollation {
|
||||||
|
|
||||||
@TextIndexed String foo;
|
@TextIndexed String foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class TextIndexOnMultiplePropertiesInRoot {
|
class TextIndexOnMultiplePropertiesInRoot {
|
||||||
|
|
||||||
@TextIndexed String foo;
|
@TextIndexed String foo;
|
||||||
|
|
||||||
@@ -890,48 +925,48 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class TextIndexOnNestedRoot {
|
class TextIndexOnNestedRoot {
|
||||||
|
|
||||||
String bar;
|
String bar;
|
||||||
|
|
||||||
@TextIndexed TextIndexOnNested nested;
|
@TextIndexed TextIndexOnNested nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TextIndexOnNested {
|
class TextIndexOnNested {
|
||||||
|
|
||||||
String foo;
|
String foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class TextIndexOnNestedWithWeightRoot {
|
class TextIndexOnNestedWithWeightRoot {
|
||||||
|
|
||||||
@TextIndexed(weight = 5) TextIndexOnNested nested;
|
@TextIndexed(weight = 5) TextIndexOnNested nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class TextIndexOnNestedWithMostSpecificValueRoot {
|
class TextIndexOnNestedWithMostSpecificValueRoot {
|
||||||
@TextIndexed(weight = 5) TextIndexOnNestedWithMostSpecificValue nested;
|
@TextIndexed(weight = 5) TextIndexOnNestedWithMostSpecificValue nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TextIndexOnNestedWithMostSpecificValue {
|
class TextIndexOnNestedWithMostSpecificValue {
|
||||||
|
|
||||||
String foo;
|
String foo;
|
||||||
@TextIndexed(weight = 10) String bar;
|
@TextIndexed(weight = 10) String bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document(language = "spanish")
|
@Document(language = "spanish")
|
||||||
static class DocumentWithDefaultLanguage {
|
class DocumentWithDefaultLanguage {
|
||||||
@TextIndexed String foo;
|
@TextIndexed String foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithLanguageOverrideOnNestedElement {
|
class DocumentWithLanguageOverrideOnNestedElement {
|
||||||
|
|
||||||
DocumentWithLanguageOverride nested;
|
DocumentWithLanguageOverride nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithLanguageOverride {
|
class DocumentWithLanguageOverride {
|
||||||
|
|
||||||
@TextIndexed String foo;
|
@TextIndexed String foo;
|
||||||
|
|
||||||
@@ -939,19 +974,19 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithNoTextIndexPropertyButReservedFieldLanguage {
|
class DocumentWithNoTextIndexPropertyButReservedFieldLanguage {
|
||||||
|
|
||||||
String language;
|
String language;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithNoTextIndexPropertyButReservedFieldLanguageAnnotated {
|
class DocumentWithNoTextIndexPropertyButReservedFieldLanguageAnnotated {
|
||||||
|
|
||||||
@Field("language") String lang;
|
@Field("language") String lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithOverlappingLanguageProps {
|
class DocumentWithOverlappingLanguageProps {
|
||||||
|
|
||||||
@TextIndexed String foo;
|
@TextIndexed String foo;
|
||||||
String language;
|
String language;
|
||||||
@@ -959,7 +994,7 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class TextIndexedDocumentWithComposedAnnotation {
|
class TextIndexedDocumentWithComposedAnnotation {
|
||||||
|
|
||||||
@ComposedTextIndexedAnnotation String foo;
|
@ComposedTextIndexedAnnotation String foo;
|
||||||
String lang;
|
String lang;
|
||||||
@@ -1248,104 +1283,104 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class MixedIndexRoot {
|
class MixedIndexRoot {
|
||||||
|
|
||||||
@Indexed String first;
|
@Indexed String first;
|
||||||
NestedGeoIndex nestedGeo;
|
NestedGeoIndex nestedGeo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NestedGeoIndex {
|
class NestedGeoIndex {
|
||||||
|
|
||||||
@GeoSpatialIndexed Point location;
|
@GeoSpatialIndexed Point location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class Outer {
|
class Outer {
|
||||||
|
|
||||||
@DBRef Inner inner;
|
@DBRef Inner inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class Inner {
|
class Inner {
|
||||||
|
|
||||||
@Indexed Outer outer;
|
@Indexed Outer outer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class CycleLevelZero {
|
class CycleLevelZero {
|
||||||
|
|
||||||
@Indexed String indexedProperty;
|
@Indexed String indexedProperty;
|
||||||
CycleLevelZero cyclicReference;
|
CycleLevelZero cyclicReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class CycleOnLevelOne {
|
class CycleOnLevelOne {
|
||||||
|
|
||||||
CycleOnLevelOneReferenced reference;
|
CycleOnLevelOneReferenced reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CycleOnLevelOneReferenced {
|
class CycleOnLevelOneReferenced {
|
||||||
|
|
||||||
@Indexed String indexedProperty;
|
@Indexed String indexedProperty;
|
||||||
CycleOnLevelOne cyclicReference;
|
CycleOnLevelOne cyclicReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
public static class CycleStartingInBetween {
|
static class CycleStartingInBetween {
|
||||||
|
|
||||||
CycleOnLevelOne referenceToCycleStart;
|
CycleOnLevelOne referenceToCycleStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class NoCycleButIdenticallyNamedProperties {
|
class NoCycleButIdenticallyNamedProperties {
|
||||||
|
|
||||||
@Indexed String foo;
|
@Indexed String foo;
|
||||||
NoCycleButIdenticallyNamedPropertiesNested reference;
|
NoCycleButIdenticallyNamedPropertiesNested reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NoCycleButIdenticallyNamedPropertiesNested {
|
class NoCycleButIdenticallyNamedPropertiesNested {
|
||||||
|
|
||||||
@Indexed String foo;
|
@Indexed String foo;
|
||||||
NoCycleButIndenticallNamedPropertiesDeeplyNested deep;
|
NoCycleButIndenticallNamedPropertiesDeeplyNested deep;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NoCycleButIndenticallNamedPropertiesDeeplyNested {
|
class NoCycleButIndenticallNamedPropertiesDeeplyNested {
|
||||||
|
|
||||||
@Indexed String foo;
|
@Indexed String foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document("rules")
|
@Document("rules")
|
||||||
static class NoCycleManyPathsToDeepValueObject {
|
class NoCycleManyPathsToDeepValueObject {
|
||||||
|
|
||||||
private NoCycleLevel3 l3;
|
private NoCycleLevel3 l3;
|
||||||
private NoCycleLevel2 l2;
|
private NoCycleLevel2 l2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NoCycleLevel2 {
|
class NoCycleLevel2 {
|
||||||
private NoCycleLevel3 l3;
|
private NoCycleLevel3 l3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NoCycleLevel3 {
|
class NoCycleLevel3 {
|
||||||
private ValueObject valueObject;
|
private ValueObject valueObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ValueObject {
|
class ValueObject {
|
||||||
@Indexed private String value;
|
@Indexed private String value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class SimilarityHolingBean {
|
class SimilarityHolingBean {
|
||||||
|
|
||||||
@Indexed @Field("norm") String normalProperty;
|
@Indexed @Field("norm") String normalProperty;
|
||||||
@Field("similarityL") private List<SimilaritySibling> listOfSimilarilyNamedEntities = null;
|
@Field("similarityL") private List<SimilaritySibling> listOfSimilarilyNamedEntities = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SimilaritySibling {
|
class SimilaritySibling {
|
||||||
@Field("similarity") private String similarThoughNotEqualNamedProperty;
|
@Field("similarity") private String similarThoughNotEqualNamedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class MultipleObjectsOfSameType {
|
class MultipleObjectsOfSameType {
|
||||||
|
|
||||||
SelfCyclingViaCollectionType cycleOne;
|
SelfCyclingViaCollectionType cycleOne;
|
||||||
|
|
||||||
@@ -1353,7 +1388,7 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class SelfCyclingViaCollectionType {
|
class SelfCyclingViaCollectionType {
|
||||||
|
|
||||||
List<SelfCyclingViaCollectionType> cyclic;
|
List<SelfCyclingViaCollectionType> cyclic;
|
||||||
|
|
||||||
@@ -1361,55 +1396,55 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
|
|
||||||
@Document
|
@Document
|
||||||
@CompoundIndex(name = "c_index", def = "{ foo:1, bar:1 }")
|
@CompoundIndex(name = "c_index", def = "{ foo:1, bar:1 }")
|
||||||
static class DocumentWithNamedCompoundIndex {
|
class DocumentWithNamedCompoundIndex {
|
||||||
|
|
||||||
String property;
|
String property;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithNamedIndex {
|
class DocumentWithNamedIndex {
|
||||||
|
|
||||||
@Indexed(name = "property_index") String property;
|
@Indexed(name = "property_index") String property;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TypeWithNamedIndex {
|
class TypeWithNamedIndex {
|
||||||
|
|
||||||
@Indexed(name = "property_index") String property;
|
@Indexed(name = "property_index") String property;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithNestedDocumentHavingNamedCompoundIndex {
|
class DocumentWithNestedDocumentHavingNamedCompoundIndex {
|
||||||
|
|
||||||
DocumentWithNamedCompoundIndex propertyOfTypeHavingNamedCompoundIndex;
|
DocumentWithNamedCompoundIndex propertyOfTypeHavingNamedCompoundIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CompoundIndex(name = "c_index", def = "{ foo:1, bar:1 }")
|
@CompoundIndex(name = "c_index", def = "{ foo:1, bar:1 }")
|
||||||
static class TypeWithNamedCompoundIndex {
|
class TypeWithNamedCompoundIndex {
|
||||||
String property;
|
String property;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithNestedTypeHavingNamedCompoundIndex {
|
class DocumentWithNestedTypeHavingNamedCompoundIndex {
|
||||||
|
|
||||||
TypeWithNamedCompoundIndex propertyOfTypeHavingNamedCompoundIndex;
|
TypeWithNamedCompoundIndex propertyOfTypeHavingNamedCompoundIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithNestedDocumentHavingNamedIndex {
|
class DocumentWithNestedDocumentHavingNamedIndex {
|
||||||
|
|
||||||
DocumentWithNamedIndex propertyOfTypeHavingNamedIndex;
|
DocumentWithNamedIndex propertyOfTypeHavingNamedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class DocumentWithNestedTypeHavingNamedIndex {
|
class DocumentWithNestedTypeHavingNamedIndex {
|
||||||
|
|
||||||
TypeWithNamedIndex propertyOfTypeHavingNamedIndex;
|
TypeWithNamedIndex propertyOfTypeHavingNamedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
public class MultiplePropertiesOfSameTypeWithMatchingStartLetters {
|
class MultiplePropertiesOfSameTypeWithMatchingStartLetters {
|
||||||
|
|
||||||
public class NameComponent {
|
class NameComponent {
|
||||||
|
|
||||||
@Indexed String component;
|
@Indexed String component;
|
||||||
}
|
}
|
||||||
@@ -1419,9 +1454,9 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
public class MultiplePropertiesOfSameTypeWithMatchingStartLettersOnNestedProperty {
|
class MultiplePropertiesOfSameTypeWithMatchingStartLettersOnNestedProperty {
|
||||||
|
|
||||||
public class NameComponent {
|
class NameComponent {
|
||||||
|
|
||||||
@Indexed String nameLast;
|
@Indexed String nameLast;
|
||||||
@Indexed String name;
|
@Indexed String name;
|
||||||
@@ -1431,39 +1466,39 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
public static class OuterDocumentReferingToIndexedPropertyViaDifferentNonCyclingPaths {
|
static class OuterDocumentReferingToIndexedPropertyViaDifferentNonCyclingPaths {
|
||||||
|
|
||||||
NoCycleButIndenticallNamedPropertiesDeeplyNested path1;
|
NoCycleButIndenticallNamedPropertiesDeeplyNested path1;
|
||||||
AlternatePathToNoCycleButIndenticallNamedPropertiesDeeplyNestedDocument path2;
|
AlternatePathToNoCycleButIndenticallNamedPropertiesDeeplyNestedDocument path2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AlternatePathToNoCycleButIndenticallNamedPropertiesDeeplyNestedDocument {
|
static class AlternatePathToNoCycleButIndenticallNamedPropertiesDeeplyNestedDocument {
|
||||||
NoCycleButIndenticallNamedPropertiesDeeplyNested propertyWithIndexedStructure;
|
NoCycleButIndenticallNamedPropertiesDeeplyNested propertyWithIndexedStructure;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class GenericEntityWrapper<T> {
|
class GenericEntityWrapper<T> {
|
||||||
T entity;
|
T entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class EntityWithGenericTypeWrapperAsElement {
|
class EntityWithGenericTypeWrapperAsElement {
|
||||||
List<GenericEntityWrapper<DocumentWithNamedIndex>> listWithGeneircTypeElement;
|
List<GenericEntityWrapper<DocumentWithNamedIndex>> listWithGeneircTypeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithHashedIndexOnId {
|
class WithHashedIndexOnId {
|
||||||
|
|
||||||
@HashIndexed @Id String id;
|
@HashIndexed @Id String id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithHashedIndex {
|
class WithHashedIndex {
|
||||||
|
|
||||||
@HashIndexed String value;
|
@HashIndexed String value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithHashedIndexAndIndex {
|
class WithHashedIndexAndIndex {
|
||||||
|
|
||||||
@Indexed //
|
@Indexed //
|
||||||
@HashIndexed //
|
@HashIndexed //
|
||||||
@@ -1471,7 +1506,7 @@ public class MongoPersistentEntityIndexResolverUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
static class WithComposedHashedIndexAndIndex {
|
class WithComposedHashedIndexAndIndex {
|
||||||
|
|
||||||
@ComposedHashIndexed(name = "idx-name") String value;
|
@ComposedHashIndexed(name = "idx-name") String value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user