[英]How to search in fulltext index using php in mongodb
I'm using mongodb 2.4 and added fulltext index to the "title" field in one the collection. 我正在使用mongodb 2.4,并将全文索引添加到集合之一的“标题”字段中。 How should I search something in that field using php? 如何使用php在该字段中搜索内容?
This is the code I use right now: 这是我现在使用的代码:
$params = array(
'_id' => array(
'$gt' => (int)$gt
)
);
$r = $this->collection->find( $params )->limit($limit);
This seem to be the answer to my question: 这似乎是我的问题的答案:
<?php
$result = $db->command(
array(
'text' => 'bar', //this is the name of the collection where we are searching
'search' => 'hotel', //the string to search
'limit' => 5, //the number of results, by default is 1000
'project' => Array( //the fields to retrieve from db
'title' => 1
)
)
);
http://www.php.net/manual/en/mongodb.command.php#111891 http://www.php.net/manual/zh/mongodb.command.php#111891
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.