Search in sources :

Example 1 with Indexed

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]);
}
Also used : Index(dev.morphia.annotations.Index) Indexed(dev.morphia.annotations.Indexed) Test(org.testng.annotations.Test)

Example 2 with Indexed

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()));
}
Also used : EntityModel(dev.morphia.mapping.codec.pojo.EntityModel) Document(org.bson.Document) Indexed(dev.morphia.annotations.Indexed) Test(org.testng.annotations.Test)

Aggregations

Indexed (dev.morphia.annotations.Indexed)2 Test (org.testng.annotations.Test)2 Index (dev.morphia.annotations.Index)1 EntityModel (dev.morphia.mapping.codec.pojo.EntityModel)1 Document (org.bson.Document)1