use of dev.morphia.annotations.Index in project morphia by mongodb.
the class IndexHelperTest method wildcardTextIndex.
@Test
public void wildcardTextIndex() {
MongoCollection<Document> indexes = getDatabase().getCollection("indexes");
EntityModel model = getMapper().getEntityModel(IndexedClass.class);
Index index = indexBuilder().fields(fieldBuilder().value("$**").type(IndexType.TEXT).build()).build();
getIndexHelper().createIndex(indexes, model, index);
List<Document> wildcard = getIndexInfo(IndexedClass.class);
boolean found = false;
for (Document document : wildcard) {
found |= document.get("name").equals("$**_text");
}
assertTrue(found, "Should have found the wildcard index");
}
use of dev.morphia.annotations.Index in project morphia by mongodb.
the class IndexHelperTest method indexPartialFilters.
@Test
public void indexPartialFilters() {
MongoCollection<Document> collection = getDatabase().getCollection("indexes");
EntityModel model = getMapper().getEntityModel(IndexedClass.class);
Index index = indexBuilder().fields(fieldBuilder().value("text").build()).options(indexOptionsBuilder().partialFilter("{ name : { $gt : 13 } }").build()).build();
getIndexHelper().createIndex(collection, model, index);
findPartialIndex(Document.parse(index.options().partialFilter()));
}
Aggregations