use of dev.morphia.annotations.Indexed in project morphia by mongodb.
the class IndexHelperTest method normalizeIndexed.
@Test
public void normalizeIndexed() {
Indexed indexed = indexedBuilder().value(IndexDirection.DESC).options(indexOptionsBuilder().name("index_name").background(true).expireAfterSeconds(42).sparse(true).unique(true).build()).build();
Index converted = getIndexHelper().convert(indexed, "oldstyle");
assertEquals(converted.options().name(), "index_name");
assertTrue(converted.options().background());
assertTrue(converted.options().sparse());
assertTrue(converted.options().unique());
assertEquals(fieldBuilder().value("oldstyle").type(IndexType.DESC).build(), converted.fields()[0]);
}
use of dev.morphia.annotations.Indexed in project morphia by mongodb.
the class IndexHelperTest method indexedPartialFilters.
@Test
public void indexedPartialFilters() {
MongoCollection<Document> collection = getDatabase().getCollection("indexes");
EntityModel model = getMapper().getEntityModel(IndexedClass.class);
Indexed indexed = indexedBuilder().options(indexOptionsBuilder().partialFilter("{ name : { $gt : 13 } }").build()).build();
getIndexHelper().createIndex(collection, model, getIndexHelper().convert(indexed, "text"));
findPartialIndex(Document.parse(indexed.options().partialFilter()));
}
Aggregations