[SERVER-44056] regression in {$meta: "textScore"} projection Created: 17/Oct/19  Updated: 29/Oct/23  Resolved: 07/Nov/19

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Ian Boros
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by JAVA-3465 Address build failure caused by chang... Closed
Documented
is documented by DOCS-13210 Investigate changes in SERVER-44056: ... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Sprint: Query 2019-11-18
Participants:

 Description   

A Java driver functional test of  {$meta: "textScore"} projection recently regressed when running against latest mongod. The regression occurred somewhere between the commit hashes 560b542 and c119ef4.

Test setup:

> db.test.insert({x: 1, y: [{a: 1, b: 2}, {a: 2, b: 3}, {a: 3, b: 4}]})
> db.test.createIndex({y: "text"})

Expected results contain a synthetic score field:

> db.test.find({}, {score: {"$meta": "textScore"}})
{ "_id" : ObjectId("5da7cc88458e2388ffaedd5f"), 
  "x" : 1, 
  "y" : [ { "a" : 1, "b" : 2 }, { "a" : 2, "b" : 3 }, { "a" : 3, "b" : 4 } ], 
  "score" : 0 
}

Results after the regression omit the score field:

MongoDB Enterprise > db.test.find({}, {score: {"$meta": "textScore"}})
{ "_id" : ObjectId("5da7ce30522390ed46b8b869"), 
   "x" : 1, 
   "y" : [ { "a" : 1, "b" : 2 }, { "a" : 2, "b" : 3 }, { "a" : 3, "b" : 4 } ] 
}

Educated guess is that the fix for SERVER-42423 is the culprit.



 Comments   
Comment by Githook User [ 07/Nov/19 ]

Author:

{'username': 'puppyofkosh', 'email': 'ian.boros@mongodb.com', 'name': 'Ian Boros'}

Message: SERVER-44056 Test that meta textScore projections result in missing when no text score available
Branch: master
https://github.com/mongodb/mongo/commit/28b2d92df6e7474a3aebd3b7a77c980a3cb8a8b1

Comment by Jeffrey Yemin [ 04/Nov/19 ]

Nope, it's fine. We'll just update the test to generate a non-zero text score

Comment by Ian Boros [ 04/Nov/19 ]

jeff.yemin I've talked with Asya and Dave and we've all agreed that we'd like to change the behavior of $meta in this case to return "missing" rather 0. In 4.2 and earlier, this behavior was inconsistent between find() and aggregate() and this is an opportunity to unify the behavior of the two just a bit more. Will this backwards breaking change be a big inconvenience for drivers in terms of updating the test?

Leaving this ticket assigned to myself. I think the "work" for this should be to create a test for the new behavior of $meta in find() (and update the design doc with the breaking change).

CC david.storch

Comment by Ian Boros [ 04/Nov/19 ]

On second thought, part of me is tempted to just break this behavior. I'm going to get a few other thoughts first though.

Comment by Ian Boros [ 04/Nov/19 ]

jeff.yemin Thanks for catching this! I'm a bit disappointed that our own test suite didn't reveal this problem.

It looks like the 4.2 projection executor (known as "ProjectionExec") would just return a default value of 0 when there was no text score associated with the Document. The 4.3/master executor doesn't have this logic. I'll try to get a fix into code review today or tomorrow.

Generated at Thu Feb 08 05:04:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.