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