use of org.springframework.data.mongodb.core.index.IndexDefinition in project spring-data-mongodb by spring-projects.
the class DefaultIndexOperationsIntegrationTests method shouldApplyPartialFilterWithMappedPropertyCorrectly.
// DATAMONGO-1467
@Test
public void shouldApplyPartialFilterWithMappedPropertyCorrectly() {
assumeThat(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_TWO), is(true));
IndexDefinition id = new Index().named("partial-with-mapped-criteria").on("k3y", Direction.ASC).partial(of(where("quantity").gte(10)));
indexOps.ensureIndex(id);
IndexInfo info = findAndReturnIndexInfo(indexOps.getIndexInfo(), "partial-with-mapped-criteria");
assertThat(info.getPartialFilterExpression()).isEqualTo("{ \"qty\" : { \"$gte\" : 10 } }");
}
use of org.springframework.data.mongodb.core.index.IndexDefinition in project spring-data-mongodb by spring-projects.
the class DefaultIndexOperationsIntegrationTests method shouldApplyPartialFilterCorrectly.
// DATAMONGO-1467
@Test
public void shouldApplyPartialFilterCorrectly() {
assumeThat(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_TWO), is(true));
IndexDefinition id = new Index().named("partial-with-criteria").on("k3y", Direction.ASC).partial(of(where("q-t-y").gte(10)));
indexOps.ensureIndex(id);
IndexInfo info = findAndReturnIndexInfo(indexOps.getIndexInfo(), "partial-with-criteria");
assertThat(info.getPartialFilterExpression()).isEqualTo("{ \"q-t-y\" : { \"$gte\" : 10 } }");
}
use of org.springframework.data.mongodb.core.index.IndexDefinition in project spring-data-mongodb by spring-projects.
the class DefaultReactiveIndexOperationsTests method shouldApplyPartialFilterCorrectly.
// DATAMONGO-1682
@Test
public void shouldApplyPartialFilterCorrectly() {
assumeTrue(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_TWO));
IndexDefinition id = new Index().named("partial-with-criteria").on("k3y", Direction.ASC).partial(of(where("q-t-y").gte(10)));
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
//
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("partial-with-criteria"))).consumeNextWith(indexInfo -> {
assertThat(indexInfo.getPartialFilterExpression()).isEqualTo("{ \"q-t-y\" : { \"$gte\" : 10 } }");
}).verifyComplete();
}
use of org.springframework.data.mongodb.core.index.IndexDefinition in project spring-data-mongodb by spring-projects.
the class DefaultReactiveIndexOperationsTests method shouldApplyPartialFilterWithMappedPropertyCorrectly.
// DATAMONGO-1682
@Test
public void shouldApplyPartialFilterWithMappedPropertyCorrectly() {
assumeTrue(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_TWO));
IndexDefinition id = new Index().named("partial-with-mapped-criteria").on("k3y", Direction.ASC).partial(of(where("quantity").gte(10)));
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
//
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("partial-with-mapped-criteria"))).consumeNextWith(indexInfo -> {
assertThat(indexInfo.getPartialFilterExpression()).isEqualTo("{ \"qty\" : { \"$gte\" : 10 } }");
}).verifyComplete();
}
use of org.springframework.data.mongodb.core.index.IndexDefinition in project spring-data-mongodb by spring-projects.
the class DefaultReactiveIndexOperationsTests method shouldFavorExplicitMappingHintViaClass.
// DATAMONGO-1682
@Test
public void shouldFavorExplicitMappingHintViaClass() {
assumeTrue(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_TWO));
IndexDefinition id = new Index().named("partial-with-inheritance").on("k3y", Direction.ASC).partial(of(where("age").gte(10)));
indexOps = new DefaultReactiveIndexOperations(template, this.template.getCollectionName(DefaultIndexOperationsIntegrationTestsSample.class), new QueryMapper(template.getConverter()), MappingToSameCollection.class);
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
//
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("partial-with-inheritance"))).consumeNextWith(indexInfo -> {
assertThat(indexInfo.getPartialFilterExpression()).isEqualTo("{ \"a_g_e\" : { \"$gte\" : 10 } }");
}).verifyComplete();
}
Aggregations