mongoDB慢速全文搜索& db崩溃

时间:2016-09-25 19:43:05

标签: php mongodb

我创建了一个这样的文本索引:

{
    "brand" : 1,
    "color" : 1,
    "han" : 1,
    "name" : 1,
    "price" : 1
}

我尝试使用此php代码搜索关键字:

// select a database
$db = $m->computerdb;

// select a collection 
$collection = $db->products;

$result = $collection->find(array('$text' => array('$search' => 'Asus')), array('pictures' => 0))->limit(1);

// iterate through the results
foreach ($result as $document) {
    echo $document["name"] . "\n";
}

获得一个结果需要超过一分钟。有时,数据库会以不同的方式崩溃,通过执行完全相同的查询:

2016-09-25T15:16:15.008-0400 F -        [conn7] out of memory.

2016-09-25T15:26:26.404-0400 E STORAGE  [conn3] WiredTiger (12) [1474831586:358439][1069:0x7f7395f5c700], file:collection-2-161678893487581897.wt, WT_CURSOR.search: memory allocation of 7098127 bytes failed: Cannot allocate memory
2016-09-25T15:26:26.540-0400 I -        [conn3] Invariant failure: seekRet resulted in status UnknownError: 12: Cannot allocate memory at src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp 527

我试图将RAM从4GB增加到16GB并重写文本索引,但仍然是同样的问题。我究竟做错了什么?该数据库计算8325个文档,大约7GB。

0 个答案:

没有答案