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


如何使用

Doctrine 查询生成器构建下面的原生 mongo db 查询?

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

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

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

最新更新