2

I have a document containing a list of keywords which I want to search on, however Mongo only ever returns a single result even though there are many documents which contain the same keyword.

The documents look something like this:

{
    _Id: 51192567f5e65101d471c46b
    Name: "Cat",
    KeyWords: ["cat", "animal", "small"]
}

I am searching the database in the mongo shell using the following:

db.Resources.find({"KeyWords":"cat"})

I wanted to get back all documents where the KeyWords array contains cat (there are many), however I just get one document.

4

2 回答 2

1

我刚刚检查了我的本地数据库,所以请检查您的结构 MongoDB

于 2013-02-12T11:32:11.647 回答
0

感谢您的回复;经过多次搜索,事实证明我用来加载数据的程序中有一段代码只存储任何关键字的一次出现,所以虽然所有文档似乎都有很多关键字,但每个关键字只会出现在一个文件中!!在程序将它们剥离之前,我正在查看在文档之间重复关键字的原始数据。

数据加载失败!!!

于 2013-02-12T11:37:34.073 回答