有这个收藏
rs-ds123584:PRIMARY> db.Task.find()
{ "_id" : ObjectId("5c11f7a00d12b470d915e609"), "description" : "xxxx", "id" : ObjectId("5c11f7a00d12b470d915e609") }
{ "_id" : ObjectId("5c12001e71795080bd2c246c"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c1200431cb44181e8719ff1"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c1201d6c37ece8562fdfb5d"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c120207d57361862cb54f48"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c120313715d4a89bbc330e0"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c12054f715d4a89bbc330e1"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c1205c5715d4a89bbc330e2"), "description" : "XXXXXX", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c1205e9d132ec8f5fc94d86"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c1206d8d132ec8f5fc94d87"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c120cc71b0bc59d11a70232"), "description" : "safdsgsd", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c120d7ceeeeab9f01a26b0e"), "description" : "stretert", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
{ "_id" : ObjectId("5c120dc609060aa06968668c"), "description" : "nw", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a"), "creatorUserId" : ObjectId("5c0f8c4a7a89e6a8b7f4bed8") }
{ "_id" : ObjectId("5c120f516c64a2a498c9255e"), "description" : "safsa", "assignedUserId" : ObjectId("5c0d073f48629a2a01e6a15a") }
它具有这样的索引
rs-ds123584:PRIMARY> db.Task.getIndexes()
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "ev.Task"
},
{
"v" : 2,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"name" : "$**_text",
"ns" : "ev.Task",
"weights" : {
"$**" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 3
}
]
但是在进行这样的文本搜索时
rs-ds123584:PRIMARY> db.Task.find({$text:{$search: 'saf'}})
rs-ds123584:PRIMARY> db.Task.find({$text:{$search: 'x'}})
响应始终为空数组。 这是什么问题 看来这里的一切都是根据文档 https://docs.mongodb.com/manual/text-search/