use of org.mongodb.morphia.annotations.Text in project morphia by mongodb.
the class IndexHelper method collectFieldIndexes.
@SuppressWarnings("deprecation")
private List<Index> collectFieldIndexes(final MappedClass mc) {
List<Index> list = new ArrayList<Index>();
for (final MappedField mf : mc.getPersistenceFields()) {
if (mf.hasAnnotation(Indexed.class)) {
final Indexed indexed = mf.getAnnotation(Indexed.class);
list.add(convert(indexed, mf.getNameToStore()));
} else if (mf.hasAnnotation(Text.class)) {
final Text text = mf.getAnnotation(Text.class);
list.add(convert(text, mf.getNameToStore()));
}
}
return list;
}
use of org.mongodb.morphia.annotations.Text in project morphia by mongodb.
the class IndexHelperTest method textPartialFilters.
@Test
public void textPartialFilters() {
MongoCollection<Document> collection = getDatabase().getCollection("indexes");
MappedClass mappedClass = getMorphia().getMapper().getMappedClass(IndexedClass.class);
Text text = new TextBuilder().value(4).options(new IndexOptionsBuilder().partialFilter("{ name : { $gt : 13 } }"));
indexHelper.createIndex(collection, mappedClass, indexHelper.convert(text, "text"), false);
findPartialIndex(BasicDBObject.parse(text.options().partialFilter()));
}
Aggregations