From 1d6d66cf35c75ccb6f846765a011803c4535acdb Mon Sep 17 00:00:00 2001 From: evanchooly Date: Mon, 23 Nov 2026 10:35:23 -0500 Subject: [PATCH] Compare documented projections and convert the cases that use them A find scenario carries the page's projection, and the runner compares Morphia's projection with it after the filter, then runs the projected query on both sides. Converted tests pass their legacy findOptions, now a mapped option. The $in and $nin cases convert after their bodies gain the page's _id exclusion, recorded as reviewed edits, and $text's relevance-score case converts unchanged; $rand's stays legacy-only because its test omits the _id exclusion the page projects. --- audits/README.md | 6 +- audits/catalog/curated-repairs.json | 8 +- audits/catalog/cutover.json | 10 +- audits/catalog/fixture-migration.json | 270 ++++++++++++++++++ .../audits/repairs/FixtureMigration.kt | 13 +- .../dev/morphia/test/OperatorCaseRunner.java | 38 ++- .../morphia/test/query/filters/TestIn.java | 4 +- .../morphia/test/query/filters/TestNin.java | 4 +- .../dev/morphia/test/generated/manifest.json | 27 ++ .../useTheInOperatorToMatchValues/action.json | 1 - .../useTheInOperatorToMatchValues/data.json | 4 - .../expected.json | 2 - .../in/useTheInOperatorToMatchValues/name | 1 - .../scenario.json | 160 +++++++++++ .../selectOnUnmatchingDocuments/action.json | 1 - .../nin/selectOnUnmatchingDocuments/data.json | 4 - .../selectOnUnmatchingDocuments/expected.json | 2 - .../nin/selectOnUnmatchingDocuments/name | 1 - .../selectOnUnmatchingDocuments/scenario.json | 149 ++++++++++ .../text/relevanceScoreExamples/action.json | 4 - .../text/relevanceScoreExamples/data.json | 8 - .../text/relevanceScoreExamples/expected.json | 1 - .../text/relevanceScoreExamples/index.json | 1 - .../filters/text/relevanceScoreExamples/name | 1 - .../text/relevanceScoreExamples/scenario.json | 175 ++++++++++++ design/operator-audits-design.md | 2 +- design/operator-audits-progress.md | 22 +- 27 files changed, 857 insertions(+), 62 deletions(-) delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/action.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/data.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/expected.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/name create mode 100644 core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/scenario.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/action.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/data.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/expected.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/name create mode 100644 core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/scenario.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/action.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/data.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/expected.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/index.json delete mode 100644 core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/name create mode 100644 core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/scenario.json diff --git a/audits/README.md b/audits/README.md index dac79847978..c921acf2547 100644 --- a/audits/README.md +++ b/audits/README.md @@ -168,11 +168,11 @@ These remain because coverage has not fully moved off them yet. Each one goes wh its users does. - **Core's legacy fixture loader** (`data.json`, `action.json`, `expected.json` through - `TemplatedTestBase`). It runs 186 legacy fixture directories; 370 cases have moved to the runner. - Of the 186: + `TemplatedTestBase`). It runs 183 legacy fixture directories; 373 cases have moved to the runner. + Of the 183: - 98 are still locked: 96 have no documented source that reproduces them, and are listed under `unresolved` in `form-review.json`; - - 16 are tracked as legacy-only in `cutover.json`; + - 15 are tracked as legacy-only in `cutover.json`; - 69 never-locked fixtures have no pinned reference. - **The legacy RST extractor** (`rst/`, `model/CodeBlock`). Cutover and the example inventory read pages through it, with tested snippets spliced in and only the mongosh content of each diff --git a/audits/catalog/curated-repairs.json b/audits/catalog/curated-repairs.json index 8334caeaff5..9c81b47e52f 100644 --- a/audits/catalog/curated-repairs.json +++ b/audits/catalog/curated-repairs.json @@ -6399,6 +6399,9 @@ "markers" : [ ], "method" : "testUseTheInOperatorToMatchValues", "options" : [ { + "argument" : "new FindOptions().projection().exclude(\"_id\")", + "name" : "findOptions" + }, { "argument" : "true", "name" : "removeIds" } ], @@ -6733,6 +6736,9 @@ "markers" : [ ], "method" : "testSelectOnUnmatchingDocuments", "options" : [ { + "argument" : "new FindOptions().projection().exclude(\"_id\")", + "name" : "findOptions" + }, { "argument" : "true", "name" : "removeIds" } ], @@ -7985,7 +7991,7 @@ "exclusion.TESTED_ELSEWHERE" : 1, "markers.lock" : 97, "markers.lockd" : 1, - "option.findOptions" : 6, + "option.findOptions" : 8, "option.orderMatters" : 107, "option.removeIds" : 61, "option.serverVersion" : 18, diff --git a/audits/catalog/cutover.json b/audits/catalog/cutover.json index 56360d8b379..adfbaa26b22 100644 --- a/audits/catalog/cutover.json +++ b/audits/catalog/cutover.json @@ -57,13 +57,9 @@ "detail" : "the shell normalizer cannot read the documented results (expected syntax)", "fixture" : "aggregation/stages/graphLookup/acrossMultipleCollections" }, { - "check" : "SOURCE", - "detail" : "the page documents a projection, which needs the unmapped findOptions", - "fixture" : "query/filters/in/useTheInOperatorToMatchValues" - }, { - "check" : "SOURCE", - "detail" : "the page documents a projection, which needs the unmapped findOptions", - "fixture" : "query/filters/nin/selectOnUnmatchingDocuments" + "check" : "SERIALIZATION", + "detail" : "the page's projection is {_id: 0, name: 1, registered: 1}; the test includes name and registered and drops _id with removeIds, so Morphia's projection lacks the _id exclusion", + "fixture" : "query/filters/rand/selectRandomItemsFromACollection" } ], "schemaVersion" : 1 } diff --git a/audits/catalog/fixture-migration.json b/audits/catalog/fixture-migration.json index d9a9739d936..48bbe745719 100644 --- a/audits/catalog/fixture-migration.json +++ b/audits/catalog/fixture-migration.json @@ -20932,6 +20932,93 @@ "scenario" : "core/src/test/resources/dev/morphia/test/query/filters/gte/performAnUpdateBasedOnEmbeddedDocumentFields/scenario.json", "scenarioSha256" : "240da48253c0ae273da07a1c1fac1d18b5460f3d4cbf47af47b25613585f1b39", "test" : "dev.morphia.test.query.filters.TestGte#testPerformAnUpdateBasedOnEmbeddedDocumentFields" + }, { + "bodyEdit" : { + "fromSha256" : "034be641386af07e7d988e4b38bdfa0037afa11b68b6a7b942228a4cf09d15b6", + "reason" : "projects _id away as the page does ({ _id: 0 }), so the runner compares Morphia's projection with the page's" + }, + "files" : { + "action.json" : "9f750997b47332412b1c7fa6a30a6953155be533e42e0d5d841a0c5ff2d070dc", + "data.json" : "3c19bf53287bf63afd65452615a4c519164d079bd292f58fce062e921dc15df3", + "expected.json" : "f7b8b1f7dba53b651bc18489993c580e8cf48b2c8b1dbb4cdbfb7377ac1c3f90", + "name" : "9df319879136500417d688da75ef7f953eb7da684391727e34679afa2f074b69" + }, + "fixture" : "query/filters/in/useTheInOperatorToMatchValues", + "kind" : "CONVERTED", + "legacyBody" : "{\n testQuery(new ActionTestOptions().removeIds(true).findOptions(new FindOptions().projection().exclude(\"_id\")),\n (query) -> query.filter(in(\"quantity\", List.of(5, 15))));\n }", + "legacyBodySha256" : "86eb890443a96069e1f9551b3585f0483896db7f7629f9c35a51b0563b56bf24", + "legacyMethod" : "testUseTheInOperatorToMatchValues", + "legacyType" : "dev.morphia.test.query.filters.TestIn", + "options" : [ { + "argument" : "new FindOptions().projection().exclude(\"_id\")", + "name" : "findOptions" + }, { + "argument" : "true", + "name" : "removeIds" + } ], + "ordered" : true, + "override" : { + "blocks" : [ { + "role" : "ACTION", + "sha256" : "9f750997b47332412b1c7fa6a30a6953155be533e42e0d5d841a0c5ff2d070dc", + "text" : "db.inventory.find( { quantity: { $in: [ 5, 15 ] } }, { _id: 0 } )" + }, { + "role" : "DATA", + "sha256" : "65e89a7da00ea78beed6e0d2553048caa73bcd8c0c38f5c1c1c44f65775a52ab", + "text" : "db.inventory.insertMany( [\n { \"item\": \"Pens\", \"quantity\": 350, \"tags\": [ \"school\", \"office\" ] },\n { \"item\": \"Erasers\", \"quantity\": 15, \"tags\": [ \"school\", \"home\" ] },\n { \"item\": \"Maps\", \"tags\": [ \"office\", \"storage\" ] },\n { \"item\": \"Books\", \"quantity\": 5, \"tags\": [ \"school\", \"storage\", \"home\" ] }\n] )" + }, { + "role" : "EXPECTED", + "sha256" : "f7b8b1f7dba53b651bc18489993c580e8cf48b2c8b1dbb4cdbfb7377ac1c3f90", + "text" : "{ item: 'Erasers', quantity: 15, tags: [ 'school', 'home' ] },\n{ item: 'Books', quantity: 5, tags: [ 'school', 'storage', 'home' ] }" + } ], + "collections" : { }, + "corrections" : [ ], + "example" : "Use the ``$in`` Operator to Match Values", + "fixture" : "query/filters/in/useTheInOperatorToMatchValues", + "fixtureFiles" : { + "action.json" : "9f750997b47332412b1c7fa6a30a6953155be533e42e0d5d841a0c5ff2d070dc", + "data.json" : "3c19bf53287bf63afd65452615a4c519164d079bd292f58fce062e921dc15df3", + "expected.json" : "f7b8b1f7dba53b651bc18489993c580e8cf48b2c8b1dbb4cdbfb7377ac1c3f90", + "name" : "9df319879136500417d688da75ef7f953eb7da684391727e34679afa2f074b69" + }, + "includes" : [ { + "blob" : "a140ad76120c4e6b1b54a9596dddb4c5d1dcb6fa", + "path" : "source/includes/fact-compatibility.rst" + }, { + "blob" : "af0e90475267dcf0a4b56e11aae76eeee3805ee4", + "path" : "source/includes/fact-environments.rst" + }, { + "blob" : "b770b45bc50f47b7b5d8cd771754c17a113b364f", + "path" : "source/includes/fact-environments-atlas-only.rst" + }, { + "blob" : "a7fa92b7a8083b9a17700e67517a1831f359c476", + "path" : "source/includes/fact-environments-onprem-only.rst" + }, { + "blob" : "b9acbd89b94e90716152e19ec82bc57d4039e3f1", + "path" : "source/includes/fact-comparison-order.rst" + }, { + "blob" : "30b290a800b4cbc61832f327768fee3bb6040468", + "path" : "source/includes/fact-atlas-search-operator.rst" + }, { + "blob" : "61c65e2f40f55fa8dc957ab209b96ea1f3cff254", + "path" : "source/includes/extracts-additional-examples.yaml" + } ], + "origin" : "52d461f742298f36a6ecf2ea02d8ebc332dc7168", + "pageBlob" : "a1ad4613f10bb5eb67174b4a35c0505b04cf34ae", + "retiredLock" : null, + "retypes" : [ ], + "rules" : [ ], + "shape" : "FIND", + "source" : { + "commit" : "4431b1043d025a36ca3b64c17b3398de606ec6e8", + "path" : "source/reference/operator/query/in.txt", + "relation" : "AT_ORIGIN" + }, + "unexpandedIncludes" : [ ] + }, + "scenario" : "core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/scenario.json", + "scenarioSha256" : "e93beb956188ae149c0c02e7c87191fc700d0752c86ffcd155809cffc8e84815", + "test" : "dev.morphia.test.query.filters.TestIn#testUseTheInOperatorToMatchValues" }, { "bodyEdit" : null, "files" : { @@ -21711,6 +21798,90 @@ "scenario" : "core/src/test/resources/dev/morphia/test/query/filters/nearSphere/specifyCenterPointUsingGeoJson/scenario.json", "scenarioSha256" : "e542a4a0092203869ffeaf3f39db98c1408fd3e1f9eeb735c45de12dd513531e", "test" : "dev.morphia.test.query.filters.TestNearSphere#testSpecifyCenterPointUsingGeoJson" + }, { + "bodyEdit" : { + "fromSha256" : "e254ac2bb597deed94e49d2786aed3012c810fc2119d81e54ed33c0cce5c3a4a", + "reason" : "projects _id away as the page does ({ _id: 0 }), so the runner compares Morphia's projection with the page's" + }, + "files" : { + "action.json" : "373434bb210f3803d3b0018f81994943e2c55d7ab296557b8f6061a4dab7cf66", + "data.json" : "3c19bf53287bf63afd65452615a4c519164d079bd292f58fce062e921dc15df3", + "expected.json" : "500d35a86e305114398679ef1d9b778b330b24e4afbc94e00a3990d4b6df2459", + "name" : "5bb6f9c2bb107684013ef614eff384bd27543b29497c4302a351020a41cfb2ad" + }, + "fixture" : "query/filters/nin/selectOnUnmatchingDocuments", + "kind" : "CONVERTED", + "legacyBody" : "{\n testQuery(new ActionTestOptions().removeIds(true).findOptions(new FindOptions().projection().exclude(\"_id\")),\n (query) -> query.filter(nin(\"quantity\", List.of(5, 15))));\n }", + "legacyBodySha256" : "acf9e36bb73c02b5a9b2aab1e67db45af999869de2ff0341d1dce58125b7565f", + "legacyMethod" : "testSelectOnUnmatchingDocuments", + "legacyType" : "dev.morphia.test.query.filters.TestNin", + "options" : [ { + "argument" : "new FindOptions().projection().exclude(\"_id\")", + "name" : "findOptions" + }, { + "argument" : "true", + "name" : "removeIds" + } ], + "ordered" : true, + "override" : { + "blocks" : [ { + "role" : "ACTION", + "sha256" : "373434bb210f3803d3b0018f81994943e2c55d7ab296557b8f6061a4dab7cf66", + "text" : "db.inventory.find( { quantity: { $nin: [ 5, 15 ] } }, { _id: 0 } )" + }, { + "role" : "DATA", + "sha256" : "65e89a7da00ea78beed6e0d2553048caa73bcd8c0c38f5c1c1c44f65775a52ab", + "text" : "db.inventory.insertMany( [\n { \"item\": \"Pens\", \"quantity\": 350, \"tags\": [ \"school\", \"office\" ] },\n { \"item\": \"Erasers\", \"quantity\": 15, \"tags\": [ \"school\", \"home\" ] },\n { \"item\": \"Maps\", \"tags\": [ \"office\", \"storage\" ] },\n { \"item\": \"Books\", \"quantity\": 5, \"tags\": [ \"school\", \"storage\", \"home\" ] }\n] )" + }, { + "role" : "EXPECTED", + "sha256" : "500d35a86e305114398679ef1d9b778b330b24e4afbc94e00a3990d4b6df2459", + "text" : "{ item: 'Pens', quantity: 350, tags: [ 'school', 'office' ] },\n{ item: 'Maps', tags: [ 'office', 'storage' ] }" + } ], + "collections" : { }, + "corrections" : [ ], + "example" : "Select on Unmatching Documents", + "fixture" : "query/filters/nin/selectOnUnmatchingDocuments", + "fixtureFiles" : { + "action.json" : "373434bb210f3803d3b0018f81994943e2c55d7ab296557b8f6061a4dab7cf66", + "data.json" : "3c19bf53287bf63afd65452615a4c519164d079bd292f58fce062e921dc15df3", + "expected.json" : "500d35a86e305114398679ef1d9b778b330b24e4afbc94e00a3990d4b6df2459", + "name" : "5bb6f9c2bb107684013ef614eff384bd27543b29497c4302a351020a41cfb2ad" + }, + "includes" : [ { + "blob" : "a140ad76120c4e6b1b54a9596dddb4c5d1dcb6fa", + "path" : "source/includes/fact-compatibility.rst" + }, { + "blob" : "af0e90475267dcf0a4b56e11aae76eeee3805ee4", + "path" : "source/includes/fact-environments.rst" + }, { + "blob" : "b770b45bc50f47b7b5d8cd771754c17a113b364f", + "path" : "source/includes/fact-environments-atlas-only.rst" + }, { + "blob" : "a7fa92b7a8083b9a17700e67517a1831f359c476", + "path" : "source/includes/fact-environments-onprem-only.rst" + }, { + "blob" : "b9acbd89b94e90716152e19ec82bc57d4039e3f1", + "path" : "source/includes/fact-comparison-order.rst" + }, { + "blob" : "6735bdad1e3d9ab5633ae02e8476a532573a7144", + "path" : "source/includes/extracts-inequality-operators-selectivity.yaml" + } ], + "origin" : "52d461f742298f36a6ecf2ea02d8ebc332dc7168", + "pageBlob" : "775fe329283a93f076bb5f64c52a06bdf141899e", + "retiredLock" : null, + "retypes" : [ ], + "rules" : [ ], + "shape" : "FIND", + "source" : { + "commit" : "4431b1043d025a36ca3b64c17b3398de606ec6e8", + "path" : "source/reference/operator/query/nin.txt", + "relation" : "AT_ORIGIN" + }, + "unexpandedIncludes" : [ ] + }, + "scenario" : "core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/scenario.json", + "scenarioSha256" : "0220aaeb04b41124da9e4d0e06fae054509b54df0e18cc61b0797fe267f870c1", + "test" : "dev.morphia.test.query.filters.TestNin#testSelectOnUnmatchingDocuments" }, { "bodyEdit" : null, "files" : { @@ -22476,6 +22647,105 @@ "scenario" : "core/src/test/resources/dev/morphia/test/query/filters/text/queryADifferentLanguage/scenario.json", "scenarioSha256" : "f96a5fc66dd8a48fa6ffcaa220857295d31e777347cf7c8f0d3adadffa7506e5", "test" : "dev.morphia.test.query.filters.TestText#testQueryADifferentLanguage" + }, { + "bodyEdit" : null, + "files" : { + "action.json" : "cdbc3077f04f77ed9b554f6f8d1f7f668358a12b723f4b2b00ecbf673f33826d", + "data.json" : "574470b15f63be72d8791c0bf646449187875df16393dd1039bb1fab077ee4e8", + "expected.json" : "0ffe2a645de0d62612dc2fa515a8bd4dfec77750307e141bfe341c3573f543c9", + "index.json" : "0d2944690866f2aa8710c6046c8d3593b32c447f1f0b2658f0394bb27fb9f362", + "name" : "4b3f900f269988fb93bdfba261a64a32564cc923dff620f2283a09064d891b90" + }, + "fixture" : "query/filters/text/relevanceScoreExamples", + "kind" : "CONVERTED", + "legacyBody" : "{\n ActionTestOptions options = new ActionTestOptions()\n .findOptions(new FindOptions().projection().project(textScore(\"score\")));\n testQuery(options, (query) -> query.filter(text(\"cake\")));\n }", + "legacyBodySha256" : "41b6b45de38e727eadf61e455de9b64f5bb0d494f39bcf2a791b1bc5e590d635", + "legacyMethod" : "testRelevanceScoreExamples", + "legacyType" : "dev.morphia.test.query.filters.TestText", + "options" : [ { + "argument" : "new FindOptions().projection().project(textScore(\"score\"))", + "name" : "findOptions" + } ], + "ordered" : true, + "override" : { + "blocks" : [ { + "role" : "ACTION", + "sha256" : "cdbc3077f04f77ed9b554f6f8d1f7f668358a12b723f4b2b00ecbf673f33826d", + "text" : "db.articles.find(\n { $text: { $search: \"cake\" } },\n { score: { $meta: \"textScore\" } }\n)" + }, { + "role" : "DATA", + "sha256" : "d939a0bdb49ef917cb388d75c95a0167985d64fa7a689b44aa187d49495b4690", + "text" : "db.articles.insertMany( [\n { _id: 1, subject: \"coffee\", author: \"xyz\", views: 50 },\n { _id: 2, subject: \"Coffee Shopping\", author: \"efg\", views: 5 },\n { _id: 3, subject: \"Baking a cake\", author: \"abc\", views: 90 },\n { _id: 4, subject: \"baking\", author: \"xyz\", views: 100 },\n { _id: 5, subject: \"Café Con Leche\", author: \"abc\", views: 200 },\n { _id: 6, subject: \"Сырники\", author: \"jkl\", views: 80 },\n { _id: 7, subject: \"coffee and cream\", author: \"efg\", views: 10 },\n { _id: 8, subject: \"Cafe con Leche\", author: \"xyz\", views: 10 }\n] )" + }, { + "role" : "EXPECTED", + "sha256" : "0ffe2a645de0d62612dc2fa515a8bd4dfec77750307e141bfe341c3573f543c9", + "text" : "{ \"_id\" : 3, \"subject\" : \"Baking a cake\", \"author\" : \"abc\", \"views\" : 90, \"score\" : 0.75 }" + }, { + "role" : "INDEX", + "sha256" : "17d16d38e69065181aa8c466ba2318f512838a0ab738a0290d0dd6a7cb3c4735", + "text" : "db.articles.createIndex( { subject: \"text\" } )" + } ], + "collections" : { }, + "corrections" : [ ], + "example" : "Relevance Score Examples", + "fixture" : "query/filters/text/relevanceScoreExamples", + "fixtureFiles" : { + "action.json" : "cdbc3077f04f77ed9b554f6f8d1f7f668358a12b723f4b2b00ecbf673f33826d", + "data.json" : "574470b15f63be72d8791c0bf646449187875df16393dd1039bb1fab077ee4e8", + "expected.json" : "0ffe2a645de0d62612dc2fa515a8bd4dfec77750307e141bfe341c3573f543c9", + "index.json" : "0d2944690866f2aa8710c6046c8d3593b32c447f1f0b2658f0394bb27fb9f362", + "name" : "4b3f900f269988fb93bdfba261a64a32564cc923dff620f2283a09064d891b90" + }, + "includes" : [ { + "blob" : "e360d3a4c226e0d9c595ed610e494dce21b2cb47", + "path" : "source/includes/extracts-atlas-search-facts.yaml" + }, { + "blob" : "a140ad76120c4e6b1b54a9596dddb4c5d1dcb6fa", + "path" : "source/includes/fact-compatibility.rst" + }, { + "blob" : "af0e90475267dcf0a4b56e11aae76eeee3805ee4", + "path" : "source/includes/fact-environments.rst" + }, { + "blob" : "b770b45bc50f47b7b5d8cd771754c17a113b364f", + "path" : "source/includes/fact-environments-atlas-only.rst" + }, { + "blob" : "a7fa92b7a8083b9a17700e67517a1831f359c476", + "path" : "source/includes/fact-environments-onprem-only.rst" + }, { + "blob" : "99ffff8b9dbf77ce27ea92414cf76853a348752d", + "path" : "source/includes/fact-text-search-language-none.rst" + }, { + "blob" : "8c95dbe444efb517395c376736ee2216096b9dfa", + "path" : "source/includes/list-text-search-restrictions-in-agg.rst" + }, { + "blob" : "e78d7ffbce773cfbca1385235582b09d9cc9a733", + "path" : "source/includes/fact-text-search-phrase-and-term.rst" + }, { + "blob" : "2eedcd0e0a4bc58be17eafd3d0856add713d5733", + "path" : "source/includes/fact-text-search-multiple-phrases.rst" + }, { + "blob" : "50afb761bede2976f652398ce19d3338b2e21947", + "path" : "source/includes/fact-text-search-score.rst" + }, { + "blob" : "4e4d5dbac144984c134f2224a091f715855df525", + "path" : "source/includes/extracts-4.4-changes.yaml" + } ], + "origin" : "8a18df9304d31169e1338ef9d17e7b582d276016", + "pageBlob" : "fe7d97c80ffc0dde4edc0b15bfa1b30c8715409a", + "retiredLock" : null, + "retypes" : [ ], + "rules" : [ ], + "shape" : "FIND", + "source" : { + "commit" : "d7f95ad70b1073047e6b3b46f5950a5e54af8a9f", + "path" : "source/reference/operator/query/text.txt", + "relation" : "AT_ORIGIN" + }, + "unexpandedIncludes" : [ ] + }, + "scenario" : "core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/scenario.json", + "scenarioSha256" : "902c67ea095d9a5b77d9c5aaac3244c3b43835b707220f86697b800de9970275", + "test" : "dev.morphia.test.query.filters.TestText#testRelevanceScoreExamples" }, { "bodyEdit" : null, "files" : { diff --git a/audits/src/main/kotlin/dev/morphia/audits/repairs/FixtureMigration.kt b/audits/src/main/kotlin/dev/morphia/audits/repairs/FixtureMigration.kt index 6e3d8e21782..bdf01a8f6b4 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/repairs/FixtureMigration.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/repairs/FixtureMigration.kt @@ -138,7 +138,12 @@ object FixtureMigration { * comparison, `serverVersion` becomes the minimum server, and `skipActionCheck` and * `skipDataCheck` become skipped checks that name their reason. */ - val mappedOptions = setOf("removeIds", "serverVersion", "skipActionCheck", "skipDataCheck") + /** + * The legacy options a converted case may keep. `findOptions` carries the projection the page + * documents, which the runner compares with the page's; it changes nothing in the scenario. + */ + val mappedOptions = + setOf("removeIds", "serverVersion", "skipActionCheck", "skipDataCheck", "findOptions") /** * [documented] with [override]'s retypes and corrections applied as it pins them: to the rows @@ -293,11 +298,9 @@ object FixtureMigration { when (documented.shape) { ActionShape.PIPELINE -> action["pipeline"] = BsonArray(documented.action) ActionShape.FIND -> { - // A projection needs the legacy findOptions, which the adapter does not map yet. - require(documented.action.size == 1) { - "${override.fixture}: a documented projection is not supported yet" - } action["filter"] = documented.action[0] + // The page's projection, when it documents one. + documented.action.getOrNull(1)?.let { action["projection"] = it } } ActionShape.UPDATE -> { require(documented.action.size == 2 && documented.action[1].isDocument) { diff --git a/core/src/test/java/dev/morphia/test/OperatorCaseRunner.java b/core/src/test/java/dev/morphia/test/OperatorCaseRunner.java index 5dc9983a24a..58064ff09c7 100644 --- a/core/src/test/java/dev/morphia/test/OperatorCaseRunner.java +++ b/core/src/test/java/dev/morphia/test/OperatorCaseRunner.java @@ -94,20 +94,36 @@ public void aggregate(OperatorCase operatorCase, Function, */ public void find(OperatorCase operatorCase, ActionTestOptions options, Function, Query> dsl) { options(operatorCase, options); - find(operatorCase, dsl); + find(operatorCase, dsl, options.findOptions()); } /** * Runs a query case: the documented filter runs through the driver, and Morphia's query as {@code dsl} builds it. */ public void find(OperatorCase operatorCase, Function, Query> dsl) { + find(operatorCase, dsl, new FindOptions()); + } + + /** + * Runs a query case whose page documents a projection: Morphia's is {@code options}', compared with the page's + * after the filter. Any other option would change the results, which the behavior check compares with the + * documented query's. + */ + public void find(OperatorCase operatorCase, Function, Query> dsl, FindOptions options) { run(operatorCase, "find", Shape.FIND, (action, collection) -> { - Query query = dsl.apply(test.getDs().find(Document.class, new FindOptions().collection(collection)) - .disableValidation()); + FindOptions found = new FindOptions().copy(options).collection(collection); + Query query = dsl.apply(test.getDs().find(Document.class, found).disableValidation()); BsonDocument filter = action.getDocument("filter"); - return new Execution(bson(List.of(((MorphiaQuery) query).toDocument())), + BsonDocument projection = action.getDocument("projection", null); + List emitted = new ArrayList<>(List.of(((MorphiaQuery) query).toDocument())); + found.projection().disableValidation(true); + Document mapped = found.projection().map(test.getMapper(), Document.class); + if (mapped != null || projection != null) { + emitted.add(mapped != null ? mapped : new Document()); + } + return new Execution(bson(emitted), reference -> new ArrayList<>(reference.getCollection(collection, BsonDocument.class).find(filter) - .into(new ArrayList<>())), + .projection(projection).into(new ArrayList<>())), () -> { try (var cursor = query.iterator()) { return bson(cursor.toList()).getValues(); @@ -165,7 +181,9 @@ private record Execution(BsonArray emitted, Function action.getArray("pipeline"); - case "find" -> new BsonArray(List.of(action.getDocument("filter"))); + case "find" -> action.containsKey("projection") + ? new BsonArray(List.of(action.getDocument("filter"), action.getDocument("projection"))) + : new BsonArray(List.of(action.getDocument("filter"))); default -> new BsonArray(List.of(action.getDocument("filter"), action.getDocument("update"))); }; } @@ -197,7 +215,10 @@ private void options(OperatorCase operatorCase, ActionTestOptions options) { } // The runner builds its own find and update options, so a test's own would be silently dropped. // FindOptions.equals leaves out timeoutMode, so it is checked on its own. - if (!options.findOptions().equals(new FindOptions()) || options.findOptions().timeoutMode() != null + // A documented projection is Morphia's findOptions; any other find option changes the results, which the behavior + // check compares. + boolean projected = scenario.getDocument("action").containsKey("projection"); + if (!projected && (!options.findOptions().equals(new FindOptions()) || options.findOptions().timeoutMode() != null) || options.hasUpdateOptions()) { differences.add("findOptions/updateOptions"); } @@ -371,7 +392,8 @@ private static void supported(OperatorCase operatorCase, BsonDocument scenario) BsonDocument action = scenario.getDocument("action"); Set fields = switch (action.getString("kind", new BsonString("")).getValue()) { case "aggregate" -> Set.of("kind", "collection", "pipeline"); - case "find" -> Set.of("kind", "collection", "filter"); + case "find" -> action.containsKey("projection") ? Set.of("kind", "collection", "filter", "projection") + : Set.of("kind", "collection", "filter"); case "update" -> Set.of("kind", "collection", "filter", "update", "multi"); default -> Set.of(); }; diff --git a/core/src/test/java/dev/morphia/test/query/filters/TestIn.java b/core/src/test/java/dev/morphia/test/query/filters/TestIn.java index 0df70a0b173..87353bc97ea 100644 --- a/core/src/test/java/dev/morphia/test/query/filters/TestIn.java +++ b/core/src/test/java/dev/morphia/test/query/filters/TestIn.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.regex.Pattern; +import dev.morphia.query.FindOptions; import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.util.ActionTestOptions; @@ -20,7 +21,8 @@ public class TestIn extends TemplatedTestBase { @Test @DisplayName("Use the ``$in`` Operator to Match Values") public void testUseTheInOperatorToMatchValues() { - testQuery(new ActionTestOptions().removeIds(true), (query) -> query.filter(in("quantity", List.of(5, 15)))); + testQuery(new ActionTestOptions().removeIds(true).findOptions(new FindOptions().projection().exclude("_id")), + (query) -> query.filter(in("quantity", List.of(5, 15)))); } /** diff --git a/core/src/test/java/dev/morphia/test/query/filters/TestNin.java b/core/src/test/java/dev/morphia/test/query/filters/TestNin.java index e893e2c37de..ae0af1a3a73 100644 --- a/core/src/test/java/dev/morphia/test/query/filters/TestNin.java +++ b/core/src/test/java/dev/morphia/test/query/filters/TestNin.java @@ -2,6 +2,7 @@ import java.util.List; +import dev.morphia.query.FindOptions; import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.util.ActionTestOptions; @@ -19,7 +20,8 @@ public class TestNin extends TemplatedTestBase { @Test @DisplayName("Select on Unmatching Documents") public void testSelectOnUnmatchingDocuments() { - testQuery(new ActionTestOptions().removeIds(true), (query) -> query.filter(nin("quantity", List.of(5, 15)))); + testQuery(new ActionTestOptions().removeIds(true).findOptions(new FindOptions().projection().exclude("_id")), + (query) -> query.filter(nin("quantity", List.of(5, 15)))); } /** diff --git a/core/src/test/resources/dev/morphia/test/generated/manifest.json b/core/src/test/resources/dev/morphia/test/generated/manifest.json index 8a1e953921a..4928f1815fd 100644 --- a/core/src/test/resources/dev/morphia/test/generated/manifest.json +++ b/core/src/test/resources/dev/morphia/test/generated/manifest.json @@ -1624,6 +1624,11 @@ "name" : "query/filters/in/matchValuesInAnArray", "scenario" : "/dev/morphia/test/generated/fixtures/filters/in/matchValuesInAnArray/scenario.json", "test" : "dev.morphia.test.generated.filters.TestIn#matchValuesInAnArray" + }, { + "kind" : "CONVERTED", + "name" : "query/filters/in/useTheInOperatorToMatchValues", + "scenario" : "/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/scenario.json", + "test" : "dev.morphia.test.query.filters.TestIn#testUseTheInOperatorToMatchValues" }, { "kind" : "CONVERTED", "name" : "query/filters/in/useTheInOperatorToMatchValuesInAnArray", @@ -1679,6 +1684,11 @@ "name" : "query/filters/nearSphere/specifyCenterPointUsingGeoJson", "scenario" : "/dev/morphia/test/query/filters/nearSphere/specifyCenterPointUsingGeoJson/scenario.json", "test" : "dev.morphia.test.query.filters.TestNearSphere#testSpecifyCenterPointUsingGeoJson" + }, { + "kind" : "CONVERTED", + "name" : "query/filters/nin/selectOnUnmatchingDocuments", + "scenario" : "/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/scenario.json", + "test" : "dev.morphia.test.query.filters.TestNin#testSelectOnUnmatchingDocuments" }, { "kind" : "CONVERTED", "name" : "query/filters/nor/norAndAdditionalComparisons", @@ -1729,6 +1739,11 @@ "name" : "query/filters/text/queryADifferentLanguage", "scenario" : "/dev/morphia/test/query/filters/text/queryADifferentLanguage/scenario.json", "test" : "dev.morphia.test.query.filters.TestText#testQueryADifferentLanguage" + }, { + "kind" : "CONVERTED", + "name" : "query/filters/text/relevanceScoreExamples", + "scenario" : "/dev/morphia/test/query/filters/text/relevanceScoreExamples/scenario.json", + "test" : "dev.morphia.test.query.filters.TestText#testRelevanceScoreExamples" }, { "kind" : "CONVERTED", "name" : "query/filters/text/textWithASingleWord", @@ -3292,6 +3307,10 @@ "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/query/filters/gte/performAnUpdateBasedOnEmbeddedDocumentFields/scenario.json", "sha256" : "240da48253c0ae273da07a1c1fac1d18b5460f3d4cbf47af47b25613585f1b39" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/scenario.json", + "sha256" : "e93beb956188ae149c0c02e7c87191fc700d0752c86ffcd155809cffc8e84815" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValuesInAnArray/scenario.json", @@ -3336,6 +3355,10 @@ "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/query/filters/nearSphere/specifyCenterPointUsingGeoJson/scenario.json", "sha256" : "e542a4a0092203869ffeaf3f39db98c1408fd3e1f9eeb735c45de12dd513531e" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/scenario.json", + "sha256" : "0220aaeb04b41124da9e4d0e06fae054509b54df0e18cc61b0797fe267f870c1" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/query/filters/nor/norAndAdditionalComparisons/scenario.json", @@ -3376,6 +3399,10 @@ "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/query/filters/text/queryADifferentLanguage/scenario.json", "sha256" : "f96a5fc66dd8a48fa6ffcaa220857295d31e777347cf7c8f0d3adadffa7506e5" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/scenario.json", + "sha256" : "902c67ea095d9a5b77d9c5aaac3244c3b43835b707220f86697b800de9970275" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/query/filters/text/textWithASingleWord/scenario.json", diff --git a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/action.json b/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/action.json deleted file mode 100644 index a1e99ecb675..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/action.json +++ /dev/null @@ -1 +0,0 @@ -db.inventory.find( { quantity: { $in: [ 5, 15 ] } }, { _id: 0 } ) \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/data.json b/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/data.json deleted file mode 100644 index ede69808e28..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/data.json +++ /dev/null @@ -1,4 +0,0 @@ -{ item: "Pens", quantity: 350, tags: [ "school", "office" ] }, -{ item: "Erasers", quantity: 15, tags: [ "school", "home" ] }, -{ item: "Maps", tags: [ "office", "storage" ] }, -{ item: "Books", quantity: 5, tags: [ "school", "storage", "home" ] } \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/expected.json b/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/expected.json deleted file mode 100644 index 0a40e67d2be..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/expected.json +++ /dev/null @@ -1,2 +0,0 @@ -{ item: 'Erasers', quantity: 15, tags: [ 'school', 'home' ] }, -{ item: 'Books', quantity: 5, tags: [ 'school', 'storage', 'home' ] } \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/name b/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/name deleted file mode 100644 index ad07067a10b..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/name +++ /dev/null @@ -1 +0,0 @@ -Use the ``$in`` Operator to Match Values \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/scenario.json b/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/scenario.json new file mode 100644 index 00000000000..9fc96e7237a --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/query/filters/in/useTheInOperatorToMatchValues/scenario.json @@ -0,0 +1,160 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "query/filters/in/useTheInOperatorToMatchValues", + "title": "Use the ``$in`` Operator to Match Values", + "context": "FILTER", + "source": { + "repository": "mongodb/docs", + "commit": "4431b1043d025a36ca3b64c17b3398de606ec6e8", + "path": "source/reference/operator/query/in.txt", + "blob": "a1ad4613f10bb5eb67174b4a35c0505b04cf34ae" + }, + "dataset": null, + "collections": { + "inventory": [ + { + "item": "Pens", + "quantity": { + "$numberInt": "350" + }, + "tags": [ + "school", + "office" + ] + }, + { + "item": "Erasers", + "quantity": { + "$numberInt": "15" + }, + "tags": [ + "school", + "home" + ] + }, + { + "item": "Maps", + "tags": [ + "office", + "storage" + ] + }, + { + "item": "Books", + "quantity": { + "$numberInt": "5" + }, + "tags": [ + "school", + "storage", + "home" + ] + } + ] + }, + "indexes": [], + "action": { + "kind": "find", + "collection": "inventory", + "filter": { + "quantity": { + "$in": [ + { + "$numberInt": "5" + }, + { + "$numberInt": "15" + } + ] + } + }, + "projection": { + "_id": { + "$numberInt": "0" + } + } + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "item", + "value": { + "text": "Erasers" + } + }, + { + "name": "quantity", + "value": { + "whole": { + "$numberInt": "15" + } + } + }, + { + "name": "tags", + "value": { + "array": [ + { + "text": "school" + }, + { + "text": "home" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "item", + "value": { + "text": "Books" + } + }, + { + "name": "quantity", + "value": { + "whole": { + "$numberInt": "5" + } + } + }, + { + "name": "tags", + "value": { + "array": [ + { + "text": "school" + }, + { + "text": "storage" + }, + { + "text": "home" + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [ + "_id" + ], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + } +} diff --git a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/action.json b/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/action.json deleted file mode 100644 index f83197250fa..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/action.json +++ /dev/null @@ -1 +0,0 @@ -db.inventory.find( { quantity: { $nin: [ 5, 15 ] } }, { _id: 0 } ) \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/data.json b/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/data.json deleted file mode 100644 index ede69808e28..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/data.json +++ /dev/null @@ -1,4 +0,0 @@ -{ item: "Pens", quantity: 350, tags: [ "school", "office" ] }, -{ item: "Erasers", quantity: 15, tags: [ "school", "home" ] }, -{ item: "Maps", tags: [ "office", "storage" ] }, -{ item: "Books", quantity: 5, tags: [ "school", "storage", "home" ] } \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/expected.json b/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/expected.json deleted file mode 100644 index af8adf3ff7b..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/expected.json +++ /dev/null @@ -1,2 +0,0 @@ -{ item: 'Pens', quantity: 350, tags: [ 'school', 'office' ] }, -{ item: 'Maps', tags: [ 'office', 'storage' ] } \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/name b/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/name deleted file mode 100644 index 6d7a4559113..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/name +++ /dev/null @@ -1 +0,0 @@ -Select on Unmatching Documents \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/scenario.json b/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/scenario.json new file mode 100644 index 00000000000..f6e3e605bfe --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/query/filters/nin/selectOnUnmatchingDocuments/scenario.json @@ -0,0 +1,149 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "query/filters/nin/selectOnUnmatchingDocuments", + "title": "Select on Unmatching Documents", + "context": "FILTER", + "source": { + "repository": "mongodb/docs", + "commit": "4431b1043d025a36ca3b64c17b3398de606ec6e8", + "path": "source/reference/operator/query/nin.txt", + "blob": "775fe329283a93f076bb5f64c52a06bdf141899e" + }, + "dataset": null, + "collections": { + "inventory": [ + { + "item": "Pens", + "quantity": { + "$numberInt": "350" + }, + "tags": [ + "school", + "office" + ] + }, + { + "item": "Erasers", + "quantity": { + "$numberInt": "15" + }, + "tags": [ + "school", + "home" + ] + }, + { + "item": "Maps", + "tags": [ + "office", + "storage" + ] + }, + { + "item": "Books", + "quantity": { + "$numberInt": "5" + }, + "tags": [ + "school", + "storage", + "home" + ] + } + ] + }, + "indexes": [], + "action": { + "kind": "find", + "collection": "inventory", + "filter": { + "quantity": { + "$nin": [ + { + "$numberInt": "5" + }, + { + "$numberInt": "15" + } + ] + } + }, + "projection": { + "_id": { + "$numberInt": "0" + } + } + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "item", + "value": { + "text": "Pens" + } + }, + { + "name": "quantity", + "value": { + "whole": { + "$numberInt": "350" + } + } + }, + { + "name": "tags", + "value": { + "array": [ + { + "text": "school" + }, + { + "text": "office" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "item", + "value": { + "text": "Maps" + } + }, + { + "name": "tags", + "value": { + "array": [ + { + "text": "office" + }, + { + "text": "storage" + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [ + "_id" + ], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + } +} diff --git a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/action.json b/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/action.json deleted file mode 100644 index 88c5d84f129..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/action.json +++ /dev/null @@ -1,4 +0,0 @@ -db.articles.find( - { $text: { $search: "cake" } }, - { score: { $meta: "textScore" } } -) \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/data.json b/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/data.json deleted file mode 100644 index 460579147df..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/data.json +++ /dev/null @@ -1,8 +0,0 @@ -{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, -{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, -{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, -{ _id: 4, subject: "baking", author: "xyz", views: 100 }, -{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, -{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, -{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, -{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/expected.json b/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/expected.json deleted file mode 100644 index 85bf2545093..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/expected.json +++ /dev/null @@ -1 +0,0 @@ -{ "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90, "score" : 0.75 } \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/index.json b/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/index.json deleted file mode 100644 index dc1043aa156..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/index.json +++ /dev/null @@ -1 +0,0 @@ -{ subject: "text" } \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/name b/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/name deleted file mode 100644 index 90e79e95fbd..00000000000 --- a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/name +++ /dev/null @@ -1 +0,0 @@ -Relevance Score Examples \ No newline at end of file diff --git a/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/scenario.json b/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/scenario.json new file mode 100644 index 00000000000..685d24e660d --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/query/filters/text/relevanceScoreExamples/scenario.json @@ -0,0 +1,175 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "query/filters/text/relevanceScoreExamples", + "title": "Relevance Score Examples", + "context": "FILTER", + "source": { + "repository": "mongodb/docs", + "commit": "d7f95ad70b1073047e6b3b46f5950a5e54af8a9f", + "path": "source/reference/operator/query/text.txt", + "blob": "fe7d97c80ffc0dde4edc0b15bfa1b30c8715409a" + }, + "dataset": null, + "collections": { + "articles": [ + { + "_id": { + "$numberInt": "1" + }, + "subject": "coffee", + "author": "xyz", + "views": { + "$numberInt": "50" + } + }, + { + "_id": { + "$numberInt": "2" + }, + "subject": "Coffee Shopping", + "author": "efg", + "views": { + "$numberInt": "5" + } + }, + { + "_id": { + "$numberInt": "3" + }, + "subject": "Baking a cake", + "author": "abc", + "views": { + "$numberInt": "90" + } + }, + { + "_id": { + "$numberInt": "4" + }, + "subject": "baking", + "author": "xyz", + "views": { + "$numberInt": "100" + } + }, + { + "_id": { + "$numberInt": "5" + }, + "subject": "Café Con Leche", + "author": "abc", + "views": { + "$numberInt": "200" + } + }, + { + "_id": { + "$numberInt": "6" + }, + "subject": "Сырники", + "author": "jkl", + "views": { + "$numberInt": "80" + } + }, + { + "_id": { + "$numberInt": "7" + }, + "subject": "coffee and cream", + "author": "efg", + "views": { + "$numberInt": "10" + } + }, + { + "_id": { + "$numberInt": "8" + }, + "subject": "Cafe con Leche", + "author": "xyz", + "views": { + "$numberInt": "10" + } + } + ] + }, + "indexes": [ + { + "collection": "articles", + "keys": { + "subject": "text" + } + } + ], + "action": { + "kind": "find", + "collection": "articles", + "filter": { + "$text": { + "$search": "cake" + } + }, + "projection": { + "score": { + "$meta": "textScore" + } + } + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "whole": { + "$numberInt": "3" + } + } + }, + { + "name": "subject", + "value": { + "text": "Baking a cake" + } + }, + { + "name": "author", + "value": { + "text": "abc" + } + }, + { + "name": "views", + "value": { + "whole": { + "$numberInt": "90" + } + } + }, + { + "name": "score", + "value": { + "exact": { + "$numberDouble": "0.75" + } + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + } +} diff --git a/design/operator-audits-design.md b/design/operator-audits-design.md index 4c71d694b94..e46e03423f2 100644 --- a/design/operator-audits-design.md +++ b/design/operator-audits-design.md @@ -110,7 +110,7 @@ A case is one documented example, described entirely by a `scenario.json` (schem | `name`, `title`, `context` | The qualified name (`aggregation/expressions/add/addNonIntegerValuesToADate`), the page's title for it, and the operator context. | | `source` | The repository, commit, path and blob of the page it came from. | | `collections`, `indexes`, `dataset` | The seed data, in extended JSON with exact BSON types; the indexes the page creates, each with its collection, keys and options; or the sample dataset the example queries instead. | -| `action` | The documented command: an aggregate pipeline, a find, or an update, with its collection. | +| `action` | The documented command: an aggregate pipeline, a find (with the page's projection, if any), or an update, with its collection. | | `expected` | The documented results, either exact BSON or `printed`: the constraints mongosh's printed output proves (see below). | | `comparison` | Result order, declared form rules, ignored fields, unordered arrays and tolerance. | | `requirements` | The minimum server version and topology. | diff --git a/design/operator-audits-progress.md b/design/operator-audits-progress.md index 7e794acb2c9..eea615501fb 100644 --- a/design/operator-audits-progress.md +++ b/design/operator-audits-progress.md @@ -18,7 +18,7 @@ how the audits work updates it too; this file records what each PR delivered. Every step of the plan (0–7) has been started. What stands: -- **On the runner:** 370 legacy cases (369 converted, 1 migrated), plus 14 generated cases. +- **On the runner:** 373 legacy cases (372 converted, 1 migrated), plus 14 generated cases. Core gate: 662 tests under each mapper; audits: 452. - **Generation:** inventory of mongodb/docs `e4b0c153` (297 pages read, tested snippets included; 437 examples owned, 145 unowned, none unnamed or ambiguous after review), reviewed DSL bindings checked against core's API, and the @@ -44,11 +44,11 @@ Step 5, generation and cutover: - **Bindings for the remaining gaps** the weekly job files as issues (today `$serializeEJSON`, `$deserializeEJSON`, `$toObject`, `$toArray`, `$hexHash`, `$percentile`, `$limit`, `$type`, a compound `$group` `_id`, `$convert` options, `$reduce` `valueAs`). -- **The remaining legacy fixtures:** 186 directories. +- **The remaining legacy fixtures:** 183 directories. - 98 are locked; 96 are unresolved in `form-review.json`. - - 16 are legacy-only in `cutover.json`. + - 15 are legacy-only in `cutover.json`. - 69 never-locked fixtures have no pinned reference. -- **Deferred cutover features:** documented projections (`findOptions`), update options +- **Deferred cutover features:** generated projections (converted cases carry theirs), update options (`arrayFilters`, `upsert`), update results as the page reads them (the whole collection, not the filter's matches), alternative commands. - **The stage pages' family** (41 unowned examples, most on sample datasets). @@ -2667,3 +2667,17 @@ no product-documentation changes. Legacy operator AsciiDoc tables are intentiona - The seven `$text` cases that were legacy-only because "the page creates an index" convert and pass under both mappers. Legacy-only: 16; 186 legacy directories; 370 cases on the runner. - Core: 692 tests under each mapper; audits: 458. + +## Documented projections (2026-11-23) + +- Branch audits-projections. A find scenario carries the page's `projection`; the runner's new + `find(case, dsl, FindOptions)` compares `[filter, projection]` with Morphia's query and + projection, and runs the projected query on both sides. Converted tests pass their legacy + `findOptions`, now a mapped option: it changes nothing in the scenario, and any non-projection + option would change the results, which the behavior check compares. +- `$in` and `$nin` (`useTheInOperatorToMatchValues`, `selectOnUnmatchingDocuments`) convert: their + bodies gained the page's `{_id: 0}` projection, recorded as reviewed body edits. + `$text`'s `relevanceScoreExamples` converts unchanged. `$rand`'s + `selectRandomItemsFromACollection` is legacy-only: the page projects `{_id: 0, name: 1, + registered: 1}`, and the test's projection omits the `_id` exclusion. +- Totals: ledger 373 cases; 15 legacy-only; 183 legacy directories. Core: 692 under each mapper.