2013-04-17 173 views
0

我正在使用mongodb 2.4並將全文索引添加到集合中的「標題」字段。我應該如何使用php搜索該領域的某些內容?如何使用MongoDB中的php在全文索引中搜索

這是我的代碼使用權現在:

$params = array(
     '_id' => array(
      '$gt' => (int)$gt 
     ) 
    ); 
$r = $this->collection->find($params)->limit($limit); 
+0

鏈接之一: //blog.mongohq.com/blog/2013/01/22/first-week-with-mongodb-2-dot-4-development-release/ – 2013-04-17 22:04:49

+0

可能是重複的問題:下面是一個例子:[link](http: //stackoverflow.com/questions/15313805/mon godb-collection-runco​​mmand-from-php) – Andreas3204

+1

@Dagon這個鏈接根本沒有提及'PHP' – andyb

回答

1

這似乎是回答我的問題:HTTP:在谷歌搜索

<?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

+0

我得到了像string(21)的結果「沒有這樣的命令:text」文本沒有作爲集合 – learner