如何在Doctrine Mongo DB中使用$ search $ text?

时间:2015-04-30 15:58:22

标签: mongodb symfony doctrine-orm

如何使用Doctrine查询构建器构建下面的本机mongo db查询?

db.Product.find({
$text: {$search: 'CaSe InSEnsitive'}, 
title: {$regex:/^CaSe InSEnsitive$/i} 
});

此查询将使用文本搜索索引加速不区分大小写的搜索!

1 个答案:

答案 0 :(得分:1)

$expr = $query->expr()->operator('$text', array(
                '$search'   => $param['title'],
                '$language' => 'en', // or one of those other languages
            ));

$query->field(null)->equals($expr->getQuery());