Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Mongodb-嵌入文档的全文搜索_Javascript_Mongodb_Full Text Search_Full Text Indexing - Fatal编程技术网

Javascript Mongodb-嵌入文档的全文搜索

Javascript Mongodb-嵌入文档的全文搜索,javascript,mongodb,full-text-search,full-text-indexing,Javascript,Mongodb,Full Text Search,Full Text Indexing,我们有一个Person集合,其中的文档如下所示: { ... address: { city: 'Miami', state: 'Florida', street: 'My favorite street' } ... } 现在,我想对地址执行全文搜索。我已在所有文档字段上创建了文本索引: db.Person.createIndex({'$**': 'text'}, {name: 'FullTextIndex'}) 有点不对劲,

我们有一个Person集合,其中的文档如下所示:

{
...
    address: {
        city: 'Miami',
        state: 'Florida',
        street: 'My favorite street'
    }
...
}
现在,我想对地址执行全文搜索。我已在所有文档字段上创建了文本索引:

db.Person.createIndex({'$**': 'text'}, {name: 'FullTextIndex'})
有点不对劲,因为它对address字段中的术语不起作用,这在我的案例中很重要

当我执行以下命令时:

db.Person.find({$text: {$search: 'Florida my favorite street'}})

它返回一个空数组。可能发生什么情况?

为了使新索引正常工作,只需删除旧索引即可

 db.collection.dropIndex(index)


为了使新索引正常工作,只需删除旧索引

 db.collection.dropIndex(index)


我遵循了上述所有步骤,它对我来说运行良好(它返回插入的文档)。您使用的是哪个版本的MongoDB?可能是因为MongoDB shell客户端版本您使用的是什么版本?MongoDB shell版本:3.0.4与我相同。。。奇怪的是…服务器版本呢?您使用的是副本集还是独立实例?我遵循了上述所有步骤,它对我来说运行良好(它返回插入的文档)。您使用的是哪个版本的MongoDB?可能是因为MongoDB shell客户端版本您使用的是什么版本?MongoDB shell版本:3.0.4与我相同。。。奇怪的是…服务器版本呢?您使用的是副本集还是独立实例?