[SERVER-9797] nscannedObjects is always 0 in text search command Created: 28/May/13  Updated: 11/Jul/16  Resolved: 03/Oct/14

Status: Closed
Project: Core Server
Component/s: Text Search
Affects Version/s: 2.5.0
Fix Version/s: 2.6.0

Type: Bug Priority: Minor - P4
Reporter: Tyler Brock Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

db.collection.insert({words: "test"})
db.collection.ensureIndex({ words: 'text'})
db.collection.runCommand('text', {search: "test"})
{
  "queryDebugString": "test||||||",
  "language": "english",
  "results": [
    {
      "score": 1.1,
      "obj": {
        "_id": ObjectId("51a50462a2414ab2f8ebcfae"),
        "words": "test"
      }
    }
  ],
  "stats": {
    "nscanned": 1,
    "nscannedObjects": 0,
    "n": 1,
    "nfound": 1,
    "timeMicros": 75
  },
  "ok": 1
}

nscannedObjects can't possibly be 0 as we don't have _id in the index



 Comments   
Comment by Ramon Fernandez Marina [ 03/Oct/14 ]

This is fixed in recent versions of MongoDB, such as 2.6.4 and 2.7.7:

> db.collection.runCommand('text', {search: "test"})
{
        "results" : [
                {
                        "score" : 1.1,
                        "obj" : {
                                "_id" : ObjectId("542ec5955c6253b85dc19485"),
                                "words" : "test"
                        }
                }
        ],
        "stats" : {
                "nscanned" : 1,
                "nscannedObjects" : 1,
                "n" : 1,
                "timeMicros" : 439
        },
        "ok" : 1
}

Generated at Thu Feb 08 03:21:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.