I have a pipeline to retrieve a document using vector search.
When I run this on the Atlas UI, I get the expected result of a single document.
However, when I run the same pipeline using pymongo, I’m getting all the documents, despite setting ‘numCandidates’ and ‘limit’ to 1. I’m not sure why this is happening.
[
{
'$vectorSearch': {
'index': 'name_embedding',
'path': 'name_embedding',
'queryVector': [
0.010432982817292213, 0.00038928649155423045, 0.007459962274879217, 0.002090602880343795, -0.011445075273513794, -0.03991016745567322, -0.040787313133478165, 0.03626663610339165, -0.017273038625717163, -0.030565181747078896, 0.07604185491800308, -0.017306774854660034, 0.027933742851018906, 0.008075651712715626, 0.03808839991688728, 0.024813124909996986, -0.0521564818918705, -0.00056139484513551, -0.023008227348327637, 0.06075926497578621, 0.05806035175919533, 0.027900006622076035, -0.0117571372538805, -0.021878058090806007, 0.012111369520425797, -0.011377601884305477, 0.012052330188453197, -0.0038712522946298122, 0.02687104605138302, -0.018251394852995872, 0.0073250168934464455, -0.04497062787413597, 0.02577461302280426, 0.01607539691030979, 0.018420075997710228, 0.016817597672343254, -0.018875518813729286, 0.0017890837043523788, 0.00035528649459593, 0.0000842092267703265, -0.02326125092804432, -0.05856639891862869, 0.07347788661718369, 0.043115124106407166, 0.049052730202674866, -0.03633410856127739, -0.026550550013780594, 0.035558171570301056, 0.03419184684753418, 0.046050190925598145, -0.016632046550512314, -0.004170663189142942, 0.0029540439136326313, 0.006228583864867687, -0.03630037233233452, 0.0023720909375697374, 0.008712426759302616, 0.05107691511511803, -0.004037825856357813, 0.028659075498580933, 0.013578902930021286, 0.00939558818936348, 0.026837309822440147, 0.03542322292923927, -0.008130473084747791, 0.02653368189930916, -0.0004720460856333375, 0.024408288300037384, -0.03528827801346779, 0.05357341095805168, -0.04007884860038757, -0.006608118303120136, 0.017593534663319588, -0.04206929728388786, -0.025302303954958916, -0.04760206490755081, 0.04001137614250183, -0.005317700561136007, 0.002983563346788287, -0.01683446578681469, 0.019415300339460373, 0.0021696723997592926, -0.000899813137948513, -0.006194847170263529, 0.023311855271458626, -0.029620563611388206, -0.09054850786924362, 0.02687104605138302, 0.021068384870886803, -0.005937607027590275, -0.004364647436887026, -0.013629507273435593, -0.0498286709189415, 0.03009287267923355, -0.006072552874684334, 0.02213108167052269, -0.0088473716750741, 0.0032112840563058853, -0.002256121952086687, 0.015619955025613308, 0.03511959686875343, -0.04979493096470833, -0.03314601629972458, -0.000002664484100023401, 0.02919885702431202, 0.028051819652318954, 0.006329793017357588, -0.021709376946091652, 0.028338579460978508, 0.026027636602520943, -0.06551609933376312, -0.031425461173057556, -0.014919924549758434, 0.006296056322753429, 0.0077551561407744884, -0.01264271792024374, 0.029333803802728653, -0.012052330188453197, 0.0031142919324338436, -0.03216766193509102, -0.03238694742321968, 0.05870134383440018, 0.023497406393289566, -0.012431864626705647, 0.02405405603349209, 0.013123461045324802, -0.040483683347702026, 0.031357988715171814, 0.016960976645350456, -0.03808839991688728, 0.010104052722454071, 0.0010558440117165446, 0.04122588783502579, -0.03964027389883995, 0.0011238439474254847, 0.03872939199209213, -0.04183313995599747, -0.02938440814614296, -0.01713809370994568, -0.008897976949810982, 0.017121225595474243, -0.01919601485133171, 0.008957015350461006, 0.022907018661499023, 0.006262320093810558, 0.012499338015913963, 0.014683770015835762, 0.0029540439136326313, 0.001399006461724639, -0.021372012794017792, 0.00877146515995264, -0.007156334817409515, -0.005060460418462753, -0.00355497351847589, 0.0004720460856333375, -0.03673894330859184, 0.011866779997944832, 0.00922690611332655, -0.022907018661499023, 0.0338207446038723, -0.020005688071250916, -0.00028939510229974985, -0.041731931269168854, -0.0172899067401886, 0.005887002684175968, 0.04055115953087807, -0.04554414749145508, -0.015333196148276329, -0.0544842928647995, 0.018234526738524437, 0.020882833749055862, 0.010837819427251816, -0.0400451123714447, 0.0028528347611427307, 0.009952239692211151, 0.01604166068136692, 0.05647474154829979, -0.03707630932331085, -0.0027178891468793154, -0.012398128397762775, -0.003263997146859765, 0.02194553054869175, 0.03957280144095421, 0.005650847684592009, 0.021743113175034523, 0.009926936589181423, 0.030261553823947906, -0.00724067585542798, -0.006144242826849222, 0.025943294167518616, -0.03636784479022026, 0.034849707037210464, 0.03464728593826294, 0.02935067191720009, 0.03043023683130741, 0.05219021812081337, 0.046724919229745865, -0.005452646408230066, -0.04186687618494034, 0.0451730452477932, 0.011681229807436466, -0.0699693039059639, -0.009640177711844444, -0.020899701863527298, -0.03425931930541992, -0.06335696578025818, -0.022350367158651352, 0.014160855673253536, 0.03140859305858612, -0.023008227348327637, 0.048681631684303284, -0.010129355825483799, -0.04267655313014984, 0.003223935142159462, -0.06109662726521492, 0.016328420490026474, 0.012414996512234211, 0.012204144150018692, -0.005393607541918755, 0.07448998093605042, -0.03866191953420639, 0.005385173484683037, 0.07489481568336487, 0.04783822223544121, -0.0038522756658494473, -0.026736101135611534, -0.05060460790991783, -0.02896270342171192, -0.0423729233443737, 0.006215932313352823, -0.0029308500234037638, 0.009007619693875313, -0.07098139822483063, -0.02678670547902584, 0.00224557938054204, 0.01916227675974369, -0.028524130582809448, -0.020224973559379578, 0.009538968093693256, -0.021962398663163185, -0.010129355825483799, -0.05512528494000435, -0.03129051625728607, -0.010424548760056496, -0.026010768488049507, -0.045780301094055176, -0.0053598713129758835, -0.015358498319983482, 0.04817558452486992, 0.03144232928752899, 0.011959555558860302, 0.041462041437625885, -0.06001706421375275, -0.005182755179703236, 0.04250786826014519, -0.02540351264178753, 0.01815018616616726, -0.006561730522662401, 0.039741482585668564, -0.02317691035568714, -0.007797326426953077, -0.008754597045481205, 0.0020336725283414125, -0.012659586034715176, 0.005241794046014547, 0.004613453056663275, 0.011765571311116219, 0.03296046704053879, -0.0024964939802885056, 0.03960653766989708, 0.020984044298529625, -0.017036885023117065, 0.01735737919807434, -0.034208714962005615, -0.038830600678920746, 0.0485466867685318, 0.03130738437175751, 0.0077425045892596245, 0.007869016379117966, 0.007843714207410812, 0.009142565540969372, -0.01687663607299328, -0.01322467066347599, -0.0906834527850151, -0.03193150833249092, -0.0088473716750741, 0.04136083275079727, 0.006785234436392784, 0.036536525934934616, 0.024492628872394562, -0.0034242449328303337, 0.006043033208698034, 0.03159414231777191, -0.07354535907506943, 0.03189777210354805, 0.02069728448987007, 0.010061882436275482, -0.023160042241215706, 0.007143683731555939, 0.0031585709657520056, 0.040787313133478165, 0.009066659025847912, -0.022704599425196648, -0.0027136721182614565, -0.022384103387594223, 0.06328949332237244, -0.009142565540969372, 0.010475153103470802, -0.006975001655519009, -0.030160345137119293, -0.07563702017068863, 0.05684584006667137, -0.023564878851175308, -0.007413574960082769, 0.012937910854816437, 0.02648307755589485, -0.029924191534519196, 0.027073465287685394, -0.0017310992116108537, -0.023851638659834862, 0.023362459614872932, -0.014919924549758434, 0.06430158764123917, -0.006068335846066475, -0.0010753478854894638, -0.01016309205442667, 0.014380142092704773, -0.017407985404133797, 0.014995831996202469, 0.003850167151540518, -0.0392354391515255, 0.004739964846521616, -0.019567115232348442, -0.04925515130162239, 0.04955877736210823, -0.027005990967154503, -0.011107711121439934, -0.009024487808346748, -0.027157805860042572, -0.012760794721543789, -0.00710994703695178, -0.020376788452267647, -0.05276373773813248, 0.04932262375950813, -0.003337795613333583, 0.03758235275745392, 0.013696979731321335, 0.0009641231736168265, 0.03054831363260746, 0.012575244531035423, -0.001335750799626112, 0.03478223457932472, -0.020309315994381905, -0.03204958513379097, 0.01928035542368889, -0.055665068328380585, 0.08386870473623276, -0.028810888528823853, -0.01573803275823593, 0.04021379351615906, -0.018723703920841217, 0.011208920739591122, 0.0201406329870224, -0.019870741292834282, -0.033011071383953094, 0.002241362351924181, -0.03657026216387749, 0.04055115953087807, 0.004001981113106012, -0.001674169092439115, 0.012904174625873566, 0.011006501503288746, 0.009235341101884842, -0.015164514072239399, 0.0013684328878298402, -0.022873282432556152, 0.012904174625873566, 0.030126608908176422, 0.05377582833170891, -0.045071836560964584, 0.0153669323772192, 0.027495170012116432, 0.0012113477569073439, -0.0049761198461055756, 0.01720556616783142, 0.01519825030118227, -0.012853570282459259, 0.0031796561088413, -0.013233104720711708, -0.07260074466466904, 0.03758235275745392, -0.012094500474631786, 0.04885031282901764, -0.011470377445220947, 0.022232290357351303, -0.04429589956998825, 0.04186687618494034, 0.06990183144807816, -0.05060460790991783, -0.03054831363260746, -0.004088430665433407, 0.02983984909951687, -0.005456863436847925, 0.0014063863782212138, -0.015603086911141872, 0.031239910051226616, -0.038526974618434906, 0.043081387877464294, 0.026348132640123367, -0.030615786090493202, 0.04760206490755081, -0.05974717065691948, 0.05475418269634247, 0.04055115953087807, 0.0025745092425495386, -0.016260946169495583, 0.021709376946091652, -0.029806112870573997, -0.027714455500245094, 0.04733217507600784, 0.006393048446625471, -0.031138701364398003, -0.018909255042672157, -0.01919601485133171, 0.018892386928200722, 0.006911745760589838, 0.016733257099986076, -0.0033103846944868565, -0.03363519534468651, -0.08946894109249115, 0.023952847346663475, -0.024711916223168373, -0.04719723016023636, 0.03017721325159073, 0.03832455351948738, -0.005882785655558109, 0.006675591226667166, 0.03697510063648224, -0.012431864626705647, 0.04223797842860222, -0.0011038129450753331, 0.02528543584048748, 0.0037826942279934883, -0.010542626492679119, -0.03275804966688156, -0.02558906190097332, -0.020494865253567696, 0.03407377004623413, -0.021405749022960663, 0.037447407841682434, -0.016598310321569443, -0.02855786681175232, -0.05289868265390396, -0.027680719271302223, 0.02509988471865654, -0.03697510063648224, -0.016674218699336052, 0.02896270342171192, 0.007746721617877483, -0.026668626815080643, -0.015156080015003681, 0.05542891100049019, -0.016893504187464714, 0.0068442728370428085, -0.0028654858469963074, -0.01476811058819294, 0.007354536093771458, 0.0532023087143898, -0.006937047932296991, 0.012668020091950893, -0.025083016604185104, -0.011445075273513794, -0.01016309205442667, -0.008176861330866814, -0.05684584006667137, -0.04092225804924965, 0.0007300768629647791, -0.011774005368351936, 0.04115841165184975, -0.019820136949419975, -0.02277207374572754, 0.008185295388102531, -0.018470682203769684, -0.029316935688257217, -0.05974717065691948, 0.06467268615961075, 0.0788082405924797, 0.008185295388102531, -0.021287670359015465, -0.03390508517622948, 0.04551040753722191, 0.059308599680662155, 0.03940412029623985, -0.023244382813572884, -0.013140329159796238, -0.04847921431064606, -0.0033356868661940098, 0.003304059151560068, -0.0014548824401572347, -0.03630037233233452, -0.0017458589281886816, -0.015619955025613308, -0.04733217507600784, -0.03606421500444412, 0.021810585632920265, 0.01071130856871605, -0.02870967984199524, ...
],
'numCandidates': 1,
'limit': 1
}
}, {
'$project': {
'id': 1,
'name': 1,
'invoice_registration_number': 1
}
}
]