use of org.springframework.data.mongodb.core.index.IndexInfo 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();
}
use of org.springframework.data.mongodb.core.index.IndexInfo in project spring-data-mongodb by spring-projects.
the class GeoSpatial2DSphereTests method indexInfoIsCorrect.
// DATAMONGO-360
@Test
public void indexInfoIsCorrect() {
IndexOperations operations = template.indexOps(Venue.class);
List<IndexInfo> indexInfo = operations.getIndexInfo();
assertThat(indexInfo.size(), is(2));
List<IndexField> fields = indexInfo.get(0).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.create("_id", Direction.ASC)));
fields = indexInfo.get(1).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.geo("location")));
}
use of org.springframework.data.mongodb.core.index.IndexInfo in project spring-data-mongodb by spring-projects.
the class GeoSpatial2DTests method indexInfoIsCorrect.
// DATAMONGO-360
@Test
public void indexInfoIsCorrect() {
IndexOperations operations = template.indexOps(Venue.class);
List<IndexInfo> indexInfo = operations.getIndexInfo();
assertThat(indexInfo.size(), is(2));
List<IndexField> fields = indexInfo.get(0).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.create("_id", Direction.ASC)));
fields = indexInfo.get(1).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.geo("location")));
}
use of org.springframework.data.mongodb.core.index.IndexInfo in project spring-data-mongodb by spring-projects.
the class DefaultIndexOperationsIntegrationTests method shouldApplyPartialDBOFilterCorrectly.
// DATAMONGO-1467
@Test
public void shouldApplyPartialDBOFilterCorrectly() {
assumeThat(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_TWO), is(true));
IndexDefinition id = new Index().named("partial-with-dbo").on("k3y", Direction.ASC).partial(of(new org.bson.Document("qty", new org.bson.Document("$gte", 10))));
indexOps.ensureIndex(id);
IndexInfo info = findAndReturnIndexInfo(indexOps.getIndexInfo(), "partial-with-dbo");
assertThat(info.getPartialFilterExpression()).isEqualTo("{ \"qty\" : { \"$gte\" : 10 } }");
}
use of org.springframework.data.mongodb.core.index.IndexInfo in project spring-data-mongodb by spring-projects.
the class DefaultIndexOperationsIntegrationTests method shouldFavorExplicitMappingHintViaClass.
// DATAMONGO-1467
@Test
public void shouldFavorExplicitMappingHintViaClass() {
assumeThat(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_TWO), is(true));
IndexDefinition id = new Index().named("partial-with-inheritance").on("k3y", Direction.ASC).partial(of(where("age").gte(10)));
indexOps = new DefaultIndexOperations(template.getMongoDbFactory(), this.template.getCollectionName(DefaultIndexOperationsIntegrationTestsSample.class), new QueryMapper(template.getConverter()), MappingToSameCollection.class);
indexOps.ensureIndex(id);
IndexInfo info = findAndReturnIndexInfo(indexOps.getIndexInfo(), "partial-with-inheritance");
assertThat(info.getPartialFilterExpression()).isEqualTo("{ \"a_g_e\" : { \"$gte\" : 10 } }");
}
Aggregations