$rerank Extension Stage unexpectedly runs on View when succeeding $search, $vectorSearch

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0, 8.3.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • Fully Compatible
    • ALL
    • v8.3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The $rerank stage runs successfully on a view if it comes after $search or $vectorSearch ($search or $vectorSearch can also be nested within $rankFusion, which also runs successfully on the View)

      Feature Flags: featureFlagExtensionViewsAndUnionWith and 

      featureFlagExtensionsInsideHybridSearch are disabled (checked via db.adminCommand)

      Reproduced on sharded and non-sharded clusters.

      Query used:

       

      db.moviesView.aggregate([
      |   {
      |     $vectorSearch: {
      |       index: "autoEmbedIndex",
      |       query: {
      |         text: "batman"
      |       },
      |       numCandidates: 1000,
      |       limit: 30,
      |       path: "autoEmbedField"
      |     }
      |   },
      |   {
      |     $rerank: {
      |       path: "plot",
      |       numDocsToRerank: 10,
      |       model: "rerank-2.5",
      |       query: {
      |         text: "batman"
      |       }
      |     }
      |   },
      |   {
      |     $addFields: {
      |       rerankScore: {
      |         $meta: "score"
      |       }
      |     }
      |   }
      | ])
      
      [
        {
          _id: ObjectId('573a13aef29313caabd2c349'),
          plot: 'After training with his mentor, Batman begins his war on crime to free the crime-ridden Gotham City from corruption that the Scarecrow and the League of Shadows have cast upon it.',
          genres: [ 'Action', 'Adventure' ],
          runtime: 140,
          metacritic: 70,
          rated: 'PG-13',
          cast: [
            'Christian Bale',
            'Michael Caine',
            'Liam Neeson',
            'Katie Holmes'
          ],
          num_mflix_comments: 1,
          poster: 'https://m.media-amazon.com/images/M/MV5BZmUwNGU2ZmItMmRiNC00MjhlLTg5YWUtODMyNzkxODYzMmZlXkEyXkFqcGdeQXVyNTIzOTk5ODM@._V1_SY1000_SX677_AL_.jpg',
          title: 'Batman Begins',
          fullplot: "When his parents were killed, billionaire playboy Bruce Wayne relocates to Asia when he is mentored by Henri Ducard and Ra's Al Ghul in how to fight evil. When learning about the plan to wipe out evil in Gotham City by Ducard, Bruce prevents this plan from getting any further and heads back to his home. Back in his original surroundings, Bruce adopts the image of a bat to strike fear into the criminals and the corrupt as the icon known as 'Batman'. But it doesn't stay quiet for long.",
          languages: [ 'English', 'Urdu', 'Mandarin' ],
          released: ISODate('2005-06-15T00:00:00.000Z'),
          directors: [ 'Christopher Nolan' ],
          writers: [
            'Bob Kane (characters)',
            'David S. Goyer (story)',
            'Christopher Nolan (screenplay)',
            'David S. Goyer (screenplay)'
          ], 

       

       

      View Definition

       

      Atlas [mongos] sample_mflix> db.getCollectionInfos({ type: "view" })
      [
        {
          name: 'moviesView',
          type: 'view',
          options: {
            viewOn: 'movies',
            pipeline: [
              { '$addFields': { autoEmbedField: { '$concat': [Array] } } }
            ]
          },
          info: { readOnly: true }
        }, 

       

      $rerank does not work if it is the first stage, or preceded by a non-$search / $vectorSearch stage.

       

       

            Assignee:
            Daniel Segel
            Reporter:
            Amy Jian
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: