Search in sources :

Example 1 with Text

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

Example 2 with Text

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

Aggregations

Text (dev.morphia.annotations.Text)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