此代码末尾的find()找不到插入的文档。
注意:我使用的是MongoDB版本3.2.15。
db['test'].createIndex(
{
name: 'text',
email: 'text',
phoneNumber: 'text'
},
{
default_language: 'none',
name: 'text_index',
$caseSensitive: false,
$diacriticSensitive: false,
} );
db['test'].insert({
name: 'Chaney Waste Management',
email: 'cliffchaney@gmail.com',
phoneNumber: '(402)555-1212'
});
db['test'].find( {
$text:
{
$search: 'manage',
$language: 'none',
$caseSensitive: false,
$diacriticSensitive: false
}
} ); // Finds nothing! Why?
如果重要,这是db.hostInfo()调用的完整结果:
{
"system" : {
"currentTime" : ISODate("2017-11-09T02:38:45.379Z"),
"hostname" : "Cliff-Surface:3001",
"cpuAddrSize" : 64,
"memSizeMB" : 16310,
"numCores" : 4,
"cpuArch" : "x86_64",
"numaEnabled" : false
},
"os" : {
"type" : "Windows",
"name" : "Microsoft Windows 8",
"version" : "6.2 (build 9200)"
},
"extra" : {
"pageSize" : NumberLong(4096)
},
"ok" : 1.0
}