MongoDB 排序使用的内存超过了最大 RAM,但是否使用了索引?

jon*_*eck 5 mongoose mongodb node.js

我正在调试一个带有分页结果的站点搜索功能,该功能在任意数量的页面后失败。

search: Executor error during find command: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.
Run Code Online (Sandbox Code Playgroud)

但是,我确信它正在使用索引:

   winningPlan:
    { stage: 'PROJECTION',
      transformBy:
       { score: { '$meta': 'textScore' },
         shootId: 1,
         title: 1,
         publishDate: 1,
         'media.images.indexImage': 1,
         'media.images.adImage': 1,
         'media.images.galleryImages': 1,
         'media.images.portrait': 1,
         'media.promos.images.410': 1,
         'media.full.full.length': 1,
         contentProducer: 1,
         performers: 1,
         site: 1 },
      inputStage:
       { stage: 'TEXT',
         indexPrefix: {},
         indexName: 'textSearchIndex',
         parsedTextQuery:
          { terms: [ 'milk' ],
            negatedTerms: [],
            phrases: [],
            negatedPhrases: [] },
         textIndexVersion: 3,
         inputStage:
          { stage: 'TEXT_MATCH',
            inputStage:
             { stage: 'TEXT_OR',
               filter:
                { '$and':
                   [ { 'status.publishStatus': { '$eq': 'PUBLISHED' } },
                     { publishDate: { '$lte': 2017-03-17T21:30:29.254Z } } ] },
               inputStage:
                { stage: 'IXSCAN',
                  keyPattern:
                   { _fts: 'text',
                     _ftsx: 1,
                     'status.publishStatus': 1,
                     publishDate: -1 },
                  indexName: 'textSearchIndex',
                  isMultiKey: true,
                  isUnique: false,
                  isSparse: false,
                  isPartial: false,
                  indexVersion: 2,
                  direction: 'backward',
                  indexBounds: {} } } } } },
   rejectedPlans: [] },
Run Code Online (Sandbox Code Playgroud)

该集合约为 1GB,35k 个对象,平均大小 28.3 KiB。

索引为 22.8 MiB:

{ 
    "description" : "text", 
    "performers.performerName" : "text", 
    "site.shortName" : "text", 
    "summary" : "text", 
    "title" : "text", 
    "status.publishStatus" : 1, 
    "publishDate" : -1
}
Run Code Online (Sandbox Code Playgroud)

查询:

{
  'status.publishStatus': 'PUBLISHED',
  'publishDate': {
    '$lte': new Date("Fri, 17 Mar 2017 21:30:29 GMT")
  },
  '$text': {
      '$search': 'milk'
  }
}
Run Code Online (Sandbox Code Playgroud)

排序:

{
  score: {
    $meta: 'textScore'
  },
  publishDate: -1
}
Run Code Online (Sandbox Code Playgroud)

实际上,它执行查找、排序、跳过、限制、精益、选择,最后执行。

它真的被索引了吗?如果不是,我应该采取什么不同的做法?

如果它被索引,我应该增加internalQueryExecMaxBlockingSortBytes吗?