You can combine Atlas Vector Search and Atlas Search queries into a hybrid search for unified results.
This tutorial demonstrates how to run a hybrid search on the
sample_mflix.embedded_movies
collection, which contains details
about movies. Specifically, this tutorial takes you through the
following steps:
Create an Atlas Vector Search index on the
plot_embedding
field. This field contains vector embeddings that represent the summary of a movie's plot.Create an Atlas Search index on the
sample_mflix.embedded_movies
collection.Run a query to combine the results from a
$vectorSearch
query and a$search
query by using the following techniques:Semantic boosting
Reciprocal rank fusion
Why Hybrid Search?
A hybrid search is an aggregation of different search methods, such as a full-text and semantic search, for the same query criteria. While full-text is effective in finding exact matches for query terms, semantic search provides the added benefit of identifying semantically similar documents even if the documents don't contain the exact query term. This ensures that synonymous and contextually similar matches are also included in the combined results of both methods of search.
Conversely, if you have tokens for proper nouns or specific keywords in your dataset that you don't expect to be considered in the training of an embedding model in the same context that they are used in your dataset, your vector search might benefit from being combined with a full-text search.
You can also set weights for each method of search per query. Based on whether full-text or semantic search results are most relevant and appropriate for a query, you can increase the weight for that search method per query.
You can apply the following techniques to achieve a hybrid search:
Technique | Semantic Boosting | Reciprocal Rank Fusion | ||
Purpose | Improves the accuracy of the full-text search results by boosting documents that match vector search. Useful when retrieving very large result sets. | Combines results from different search methods into a single ranked result set by calculating the reciprocal rank of documents in the results. | ||
Ranking Method |
|
| ||
Scoring Method | Boosts the full-text results score for documents that match the results from the vector search, by the weighted vector search score. | Calculates the score by using the following formula:
Then, for each method of search, applies different weights (
| ||
Search Features |
| Supports further processing of results in subsequent aggregation
stages such as | ||
Output | Single result set that contains documents from | Single result set that contains documents from both search methods. |
Prerequisites
Before you begin, you must have the following:
An Atlas cluster with MongoDB version v6.0.11, or v7.0.2 or later.
Note
Ensure that your Atlas cluster has enough memory to store both Atlas Search and Atlas Vector Search indexes and run performant queries.
The sample_mflix data loaded into your Atlas cluster.
mongosh
to run queries on your Atlas cluster:Project Data Access Admin
access to the project to create Atlas Vector Search and Atlas Search indexes.
Create the Atlas Vector Search and Atlas Search Indexes
This section demonstrates how to create the following indexes on the
fields in the sample_mflix.embedded_movies
collection:
An Atlas Vector Search index on the
plot_embedding
field for running vector queries against that field.An Atlas Search index on the
title
field for running full-text search against that field.
Procedure
Connect to the Atlas cluster using mongosh
.
To learn more, see Connect via mongosh
.
Define the Atlas Vector Search index.
Run the following command. This index definition indexes the plot_embedding
field as
the Atlas Vector Search field when querying the collection.
1 db.embedded_movies.createSearchIndex( 2 "hybrid-vector-search", 3 "vectorSearch", 4 { 5 "fields": [ 6 { 7 "type": "vector", 8 "path": "plot_embedding", 9 "numDimensions": 1536, 10 "similarity": "dotProduct" 11 } 12 ] 13 } 14 );
Semantic Boosting
This section demonstrates how to query the data in the
sample_mflix.embedded_movies
collection for star wars in the
plot_embedding
and plot
fields by using the
$vectorSearch
and $search
pipeline stages,
respectively. The query enhances relevancy of $search
queries by boosting the full-text scores using
$vectorSearch
scores for the same documents.
Procedure
Create the file for the embeddings.
Create a file named
query-embeddings.js
.touch query-embeddings.js Copy and paste the following embeddings into the file.
QUERY_EMBEDDING = [-0.003091304,-0.018973768,-0.021206735,-0.031700388,-0.027724933,-0.008654361,-0.022407115,-0.01577275,-0.0026105063,-0.03009988,0.023659125,0.0020603316,0.009796659,0.0029944992,0.012152246,0.03180365,0.026343849,-0.022265134,0.022562003,-0.030358028,0.0007740361,0.012294226,0.008228419,-0.018638177,0.012462022,-0.0106098205,0.0037366704,-0.033507414,0.00019018135,-0.02445938,0.02609861,-0.030564545,-0.020574275,-0.021787563,-0.011500426,-0.012384578,0.008796342,-0.013449432,0.016856967,0.0030412883,0.016766615,0.01871562,-0.019709485,-0.01524355,-0.028396113,0.0024749795,0.022587817,-0.024097975,-0.0053339517,0.010500109,-0.0028057296,0.040942032,-0.03585655,-0.013772115,-0.008880239,0.008525288,-0.0075314236,-0.007621775,0.02909311,-0.016844058,0.0084413905,0.0137979295,-0.023839828,0.014572369,-0.03270716,0.0031042115,-0.00033397702,-0.008564009,0.009828928,0.0016053484,0.041458327,0.016844058,0.0059954524,0.0076088677,-0.006840882,-0.009996722,0.010500109,0.014223872,-0.006450435,0.009757937,0.016960224,-0.0116940355,-0.0078992825,0.008796342,0.021348715,-0.006756984,-0.013230007,0.0031687482,-0.031622946,0.0047628027,0.0011084165,-0.0027347393,0.009473976,0.023426794,-0.020961495,0.019980539,-0.009048034,0.03337834,0.0051629297,-0.035133738,0.0029089882,0.0053436323,-0.014946681,-0.02368494,-0.009538513,0.009396533,0.016805336,0.0078992825,0.0183284,-0.0040625804,-0.011351991,0.021593954,0.0052952296,-0.039186638,-0.016856967,-0.022058617,-0.00041948803,-0.00967404,0.007563692,-0.029144738,0.026718162,0.017011853,0.016431024,-0.012087709,0.028860778,0.02199408,-0.015785657,0.00085349684,-0.019709485,-0.017153835,0.035469327,0.012655632,0.024007624,-0.0023087976,-0.029970808,0.022226412,0.0058566984,0.016637541,-0.016108342,-0.010680811,0.0043917173,0.025337078,-0.007821838,-0.0019619134,-0.0063568573,0.009906371,0.012223236,0.030074066,0.010048352,-0.020651719,0.017683035,-0.023052482,0.021529417,0.00477571,0.007757302,0.0057986155,-0.0046756784,-0.0053210445,-0.0015359716,-0.006744077,-0.00543721,0.004853154,0.01087442,-0.017863737,0.021723026,0.021581046,0.017670127,0.0116940355,-0.018367123,-0.0026153466,-0.015333901,0.030512914,-0.018225143,0.028525187,0.00008117497,0.024381936,0.009841835,0.019864373,-0.032836232,-0.027466787,-0.023710756,0.012003812,0.021116383,0.027879821,-0.0039270534,0.0070925746,0.0060664425,0.01288151,0.01794118,-0.011939275,0.00028375947,0.023465516,0.010635635,0.0024523917,-0.6790285,-0.02618896,0.019477153,-0.008680176,0.009693401,0.017360352,0.022794334,0.017295815,-0.006134206,-0.013655949,-0.014314223,0.005788935,0.011235826,-0.012074802,-0.011042216,-0.007783117,0.018405845,-0.012087709,0.008241327,-0.00088011817,-0.026330942,0.02324609,0.0039431877,-0.015217735,0.023568774,0.013513968,0.00024806263,-0.009067396,-0.028241226,0.026318034,-0.020509738,0.020148333,0.0045788735,0.004349768,0.044375382,0.002174884,-0.031080836,0.03714728,0.024807878,0.020535553,-0.012119978,-0.0034720702,0.0059567303,0.008131614,-0.015398438,0.017876644,0.027079567,-0.0037721656,-0.014159335,-0.0016731119,0.0030719433,-0.0023910818,0.005634047,0.0029380298,0.010151611,0.0074088043,0.025711391,-0.0116294995,0.002274916,0.018354215,0.00010487201,0.0156824,-0.0054565715,-0.0010777616,-0.006489157,0.03719891,-0.01601799,0.016650448,0.0004594201,-0.018831786,0.013081573,0.010784069,-0.0026718162,-0.0036624533,0.01170049,0.038024977,0.020612998,-0.000036679994,-0.0066795405,0.024381936,0.008531742,0.0004892683,-0.024446473,0.008428483,0.023749476,0.0026992443,-0.028499372,0.014533647,0.0126879,0.0044239853,0.015656585,0.003555968,-0.013552691,-0.007931551,0.009706308,-0.0113649,-0.034049522,0.0019651402,0.01577275,-0.030332213,-0.0024991806,0.013617227,-0.0048789685,-0.0025830783,0.0066795405,0.0022733025,0.008860879,0.020083796,0.03392045,-0.04269743,0.0071764723,-0.010093528,-0.023078296,-0.012216782,0.008409122,-0.021929543,0.036269583,0.00044772282,0.012642724,-0.024627175,0.023220276,-0.003823795,0.004243283,-0.007512063,0.0021361622,0.0027234454,0.0041367975,-0.027492601,-0.003910919,-0.0054952935,-0.0027089247,0.020651719,0.015953453,-0.008209058,0.0069957697,-0.0016666582,-0.0041335705,-0.008467205,0.004033539,-0.030693617,-0.02334935,0.006931233,-0.0067505306,0.012016719,0.0041529317,-0.025905,-0.0015287113,-0.005840564,-0.009796659,0.00021236582,-0.01117129,-0.0013730166,-0.017786292,0.0052468274,0.005705037,-0.0032106969,-0.022652354,-0.008525288,-0.00045538653,-0.018689806,0.005059671,0.0007611288,-0.0021603634,-0.008931869,0.017915366,-0.020651719,0.0014464271,0.011132567,-0.026214777,-0.016560096,0.028551001,-0.0038334753,-0.0042142416,0.028551001,-0.024704618,0.026692348,-0.023697848,-0.02373657,0.0077056726,0.0016521375,0.0005279902,0.003762485,-0.013029944,0.013785022,0.019425523,0.007699219,0.012068348,0.0094288,0.0043917173,0.0024604588,-0.01847038,0.015411345,-0.01432713,0.0035688751,-0.00634395,-0.016147062,-0.007860561,0.009377171,0.02315574,0.020961495,0.034746516,-0.013436525,0.020225778,-0.029118923,0.009002859,-0.04796362,0.0033107288,-0.020729164,0.01668917,-0.000113342445,0.019696577,0.013552691,0.0073378137,-0.015927639,0.021309992,0.03487559,-0.0053920345,0.00051024265,-0.021671398,0.00791219,-0.0033817189,-0.014623999,0.009048034,0.0013923777,-0.02436903,0.007860561,0.019851465,0.016895687,0.017050575,-0.020380665,-0.008331678,-0.012132885,-0.0057857083,0.026163146,-0.015269365,0.015475882,0.010945411,-0.027776562,0.031080836,-0.0027557136,-0.0065181986,0.0029218956,0.039005935,0.012765344,-0.0005126628,0.006957048,0.04274906,-0.008964137,-0.010674357,-0.0029138285,-0.010280684,-0.016727893,-0.004817659,0.0148176085,0.00536622,-0.03193272,0.015475882,0.0024120563,0.03944478,0.020032167,0.014572369,0.013720485,0.009106117,-0.013501061,-0.0060406276,0.013371988,0.0017086071,0.025943723,0.0030316077,0.007344268,0.00026258337,-0.00012907325,0.008150975,-0.01582438,-0.0011447184,-0.012662085,0.009086756,0.0021232548,0.0012544306,0.013513968,0.011055123,-0.0315455,0.010190332,0.011777934,-0.009996722,-0.0227298,-0.01934808,-0.022329671,0.0027476468,0.02870589,-0.02195536,0.021180918,0.013423617,-0.004885422,-0.037947536,0.0068666968,0.0133203585,-0.01582438,0.022639448,0.010938957,-0.002100667,0.012455568,-0.014288408,-0.020587182,0.009893464,-0.009828928,0.005521108,-0.024214141,0.014933774,-0.018173512,-0.005959957,-0.0067376234,-0.030796876,-0.0040625804,0.0027815285,0.002558877,-0.017734664,-0.006208423,0.048170134,0.0101387035,0.009461069,-0.014830516,-0.0038818778,0.002010316,0.074655965,0.0007425745,0.0125781875,0.011487518,0.0021668172,-0.0100031765,-0.024485195,-0.0022023122,-0.014223872,-0.017153835,-0.0016569778,-0.007144204,0.01949006,0.010319406,-0.0013334879,0.012468475,0.018263863,-0.0052629616,0.012739529,0.001032586,-0.01683115,-0.011907007,0.019309357,-0.0053984886,0.028551001,-0.030306397,0.0108808745,0.011080938,-0.009499791,-0.037018206,-0.02407216,-0.006379445,-0.020587182,0.013939911,0.011777934,-0.0063310424,0.0047079464,0.015282272,0.016289044,-0.02137453,0.0012996062,0.020187056,-0.0010172585,-0.013552691,0.0045401515,-0.008118707,-0.0118295625,0.027286084,-0.005563057,-0.03381719,0.018496197,-0.011500426,-0.012907324,-0.000307759,-0.00030332213,0.011513334,-0.004946732,-0.01275889,-0.019541688,-0.005743759,-0.011139021,-0.030228954,0.018534917,0.0074023507,-0.007344268,-0.013042851,-0.015475882,-0.02301376,-0.007931551,-0.001060014,-0.008363946,0.005708264,0.0013342947,0.006976409,0.019128654,-0.02049683,0.014159335,0.00548884,0.013746301,0.021000218,-0.011732758,0.0008591438,-0.008731805,-0.018831786,0.011532694,0.00048684815,0.026924679,-0.0046950392,0.0024959538,0.0025330624,0.019890187,-0.0016271296,0.0036979485,-0.00046305027,0.015475882,0.005133888,0.007970273,-0.0005586451,0.017205464,0.006685994,-0.0046982663,-0.015695307,0.01126164,0.0057857083,-0.002473366,-0.0038334753,0.009248098,0.014056076,-0.014933774,-0.010099981,-0.007944458,-0.028886592,0.004791844,-0.009609503,0.004736988,0.033481598,-0.0008470432,0.0063955793,0.002445938,-0.02248456,0.0040399926,-0.040270854,-0.0066279112,0.023710756,-0.0056275935,0.0008333291,0.01177148,-0.01934808,-0.003113892,0.0031848822,-0.024665898,0.013668857,0.009383624,0.019502968,-0.040270854,-0.007292638,-0.017631406,0.016740799,-0.00464341,0.0052984566,-0.03676006,-0.013346174,0.01799281,-0.024678804,0.003475297,-0.026511645,-0.010480748,-0.0022862097,-0.007492702,0.005156476,-0.022987945,0.008822156,-0.0011713397,-0.02199408,-0.0045369244,-0.0437042,-0.012216782,-0.03603725,0.026847234,0.020096704,0.036011435,-0.0075765993,0.024175419,-0.014740164,-0.00399159,0.010990587,0.008092892,0.016366487,0.0017925047,0.034178596,0.029454514,-0.0008704377,0.009364264,0.006340723,0.028499372,0.01804444,0.0015504924,0.008344585,-0.008228419,-0.0037528046,-0.005524335,0.013888281,-0.008822156,-0.00588574,-0.014081891,-0.007299092,0.009002859,0.013836652,0.0007349108,0.006363311,0.036682617,-0.022549096,0.018741434,-0.015901824,0.021439066,-0.0162116,0.00012140952,-0.009435254,0.009131932,-0.0062632794,0.01808316,-0.017502332,-0.027983079,0.017153835,-0.0022410343,0.03608888,-0.011151928,0.001871562,0.00022749159,-0.022497466,-0.0065440135,-0.019567505,-0.011894099,-0.044736788,-0.016869873,0.00032772502,-0.004278778,0.023852736,-0.018354215,-0.015024126,0.013836652,0.0062181037,0.025814649,0.0026347076,0.037457056,0.00745398,-0.010629182,-0.0040141777,-0.005459798,-0.0218521,0.0029186688,0.0071893795,0.015230643,-0.025362892,-0.003133253,0.0042336024,-0.016818244,-0.039109193,-0.028137967,0.007202287,0.0004933018,0.029480329,-0.028008893,-0.022820149,-0.032939494,0.0077121262,-0.016637541,0.002531449,-0.02489823,-0.039780375,-0.015811473,-0.0075314236,-0.009880557,0.01996763,-0.010945411,-0.02580174,0.010442025,-0.010119342,0.0070086773,-0.016534282,-0.030564545,0.023168648,-0.0027557136,0.00060906436,0.018625269,0.0084413905,-0.022161877,-0.000673601,0.016250322,0.022936316,-0.014778886,-0.016456839,-0.0030461287,0.005098393,0.02001926,-0.002992886,-0.011939275,-0.017695941,-0.012436207,-0.0036398654,0.006666633,-0.000830909,-0.02171012,-0.020806607,-0.005388808,-0.020858236,-0.016392302,-0.005840564,0.008583371,-0.03131317,-0.006744077,-0.003843156,-0.031003393,0.006014813,-0.0005441244,-0.0100031765,0.0069957697,0.040012706,-0.02754423,-0.010145157,-0.018238049,0.013617227,-0.032681346,0.001777984,-0.0055695106,-0.023568774,0.0253758,-0.020419387,-0.019283542,0.00065424,0.016521376,0.0005844598,0.012352309,0.008860879,0.024588453,0.023697848,-0.010222601,-0.025117652,-0.015024126,0.01177148,-0.0015650131,-0.0005465445,0.010835699,-0.030564545,0.01755396,-0.0050015883,0.011042216,-0.00568245,-0.029170552,-0.010261323,-0.01963204,0.04215532,-0.015540418,-0.011351991,-0.032190867,0.003459163,-0.0073378137,0.034901407,-0.0024523917,-0.008396215,0.0033591313,0.033455785,0.018935045,0.0006772312,0.005653408,0.00340108,0.00967404,-0.018534917,-0.0121006165,-0.0049596396,0.001681179,0.02301376,0.0058954204,-0.016314859,-0.0068279747,0.009190015,-0.019373894,-0.00075185165,-0.0038947852,0.013359081,0.0055275615,-0.0010293592,0.00006201566,0.017760478,-0.010087074,-0.010041898,-0.0036398654,0.015604955,0.023517145,-0.010074167,0.010822792,0.0070603066,-0.022678168,0.0028218639,0.017205464,0.0062019695,0.013849559,-0.0074733407,0.004817659,-0.01046784,-0.019193191,-0.0038528363,-0.005727625,0.017670127,0.014314223,-0.027311899,0.001294766,0.0009309408,0.0044239853,-0.016314859,-0.0021894048,0.019709485,-0.021439066,0.0013157404,0.006095484,-0.021826286,-0.014611091,-0.029454514,0.0101387035,0.007776663,-0.01203608,0.021142198,0.013055759,-0.0035624215,-0.01085506,-0.012887963,0.0039076926,-0.013772115,-0.0018199327,-0.018702714,0.007860561,-0.013100934,0.0043271803,-0.045898445,0.031855278,-0.019219005,0.008351039,-0.026330942,0.014094798,0.004217468,-0.0058115227,0.011726304,0.009073849,0.01504994,-0.013436525,0.00025391128,-0.0007175666,-0.0025604905,0.009073849,0.020625904,-0.0061761546,-0.012042534,0.0017505558,0.0027524868,-0.004569193,0.036889132,0.22551677,-0.011422982,0.0031510005,0.045330524,-0.00017263547,0.03632121,0.016495561,0.003342997,-0.025388706,0.009499791,-0.027002122,0.012326495,0.013694671,0.00037007718,0.0026056662,-0.028576816,-0.01630195,-0.01741198,-0.037353795,-0.019864373,-0.001844134,-0.0023555867,-0.016043805,-0.019231914,0.006769892,-0.011836017,-0.0029218956,-0.0087124435,0.018973768,0.027828192,-0.008525288,-0.0021329354,0.004178746,-0.0054178494,-0.016611727,0.008635,-0.004891876,-0.0011818269,0.0036366386,0.005937369,-0.019606225,0.010596913,-0.00615034,0.030177325,-0.01256528,0.02493695,-0.00948043,0.01263627,0.015075755,0.014791794,-0.027802376,-0.020522647,0.03392045,0.061438866,-0.015669491,0.010261323,-0.003820568,0.003514019,-0.007370082,0.00032328814,-0.0041174367,0.015398438,-0.025479058,0.017670127,-0.012113524,0.009686947,-0.03864453,0.019954724,0.016844058,-0.013643042,0.0046143685,-0.03053873,-0.015992176,-0.01683115,-0.032965306,-0.01640521,0.029015666,0.003910919,-0.010332313,0.017089298,0.011345538,-0.0366568,-0.010054805,-0.021064753,-0.025078932,-0.046931032,0.015927639,-0.0025298356,-0.009777298,0.02402053,-0.013230007,-0.0069828625,-0.015024126,-0.02010961,0.01760559,-0.011371353,0.009396533,0.00726037,-0.026589088,-0.008002541,-0.024317399,-0.013927003,0.009641771,0.005714718,-0.016121248,0.020225778,0.0010366195,0.012784705,-0.01237167,0.0050144955,0.012029626,-0.019412616,0.01073244,0.007099028,-0.019993445,0.018418752,0.0027783015,0.007918644,0.027105382,-0.03193272,0.0015980881,0.011248733,0.012384578,-0.0057243984,0.0045756465,-0.024730433,-0.007563692,0.0094288,0.0025943723,-0.02981592,-0.0077895704,-0.017089298,0.018212235,-0.011061577,-0.0068989648,0.007963819,-0.000080267426,0.0051693833,-0.004314273,0.016327765,-0.01111966,0.0049402784,-0.0058825132,0.020819515,0.022432929,-0.0154242525,0.008880239,0.009015766,0.0031493872,-0.013668857,-0.010112889,-0.01543716,0.00764759,-0.02629222,0.012804066,-0.026356757,-0.036734246,-0.02803471,-0.016469747,0.029273812,-0.030796876,0.010461386,0.02513056,0.002694404,-0.024446473,-0.030693617,-0.16603982,0.03203598,0.02329772,-0.004624049,0.018289678,0.0037366704,0.011777934,0.001595668,0.02010961,0.0014803087,0.021684306,0.0029590041,-0.034953035,0.009712761,0.026460014,0.014198056,0.001739262,0.013100934,0.0018279998,0.008312317,0.023891458,-0.020819515,-0.0058599254,-0.011797295,-0.003005793,-0.012081255,0.007415258,0.022497466,-0.0024201234,0.005459798,-0.017773386,-0.009570781,0.033068564,0.004998361,0.0109518645,0.012971861,-0.01635358,-0.022148969,0.00041041258,0.02909311,0.02151651,0.007834746,0.029867548,-0.0014561075,0.0048047514,0.020264499,0.0057405327,0.00075548183,0.013836652,-0.015992176,-0.006308455,-0.019838559,-0.008964137,-0.010822792,0.009506244,0.023839828,0.014727257,0.007053853,-0.0016400369,-0.02301376,-0.008538195,-0.018457474,0.005369447,-0.017902458,-0.016069619,-0.020483924,-0.0007768596,-0.007279731,-0.010345221,0.012752436,0.00029182652,-0.0003874214,-0.0017973449,0.0029025346,0.016676264,0.000081225386,-0.013759208,0.030409656,-0.01281052,-0.005598552,-0.022252228,0.032991122,0.011093846,-0.0009761164,0.006989316,0.0114939725,-0.010654996,-0.007776663,-0.023258999,-0.015385531,0.020587182,-0.012010265,-0.00366568,-0.0014367466,0.012694353,0.026563274,0.00372699,-0.009712761,0.00733136,0.004069034,-0.0016860192,-0.0072732773,-0.00032490154,0.03087432,0.021284178,0.024420658,0.016882781,0.011132567,0.019141562,0.010209694,-0.004081941,-0.00056832563,0.014456203,0.017373258,0.004010951,0.024975672,0.0059954524,-0.0114939725,0.033791374,0.0020022488,0.0488155,-0.0007268437,-0.021103475,-0.0019231914,-0.010132249,-0.007376536,-0.06908,-0.021981174,0.02320737,-0.00017374469,-0.01452074,0.012203875,-0.008280048,0.00582443,-0.014004447,0.009577234,0.00085027,-0.046724513,-0.0006606937,-0.012081255,0.008822156,-0.0060051326,-0.01053883,-0.001085022,-0.008744712,0.015037033,0.0039786827,0.011887645,0.011429436,0.006553694,-0.011635953,-0.0018167059,-0.021542324,0.035236996,0.009467523,0.012210329,0.0012850855,0.010945411,-0.003685041,-0.01924482,-0.02160686,0.0018957633,-0.021426158,-0.01256528,0.0034882044,-0.056895487,0.008486566,0.025066024,-0.013139656,-0.03211342,-0.014598184,-0.009519151,0.010713079,0.01111966,0.016727893,-0.022213506,-0.034462556,-0.02373657,-0.014172242,0.0023975356,0.023955993,-0.006553694,0.016856967,-0.008157429,-0.00274442,-0.00054896466,-0.0016126088,0.002073239,-0.0033559042,0.017670127,0.00063891255,0.004543378,-0.0064343014,-0.021400344,0.010519469,-0.019167377,-0.020006353,0.0033881727,-0.035004664,-0.0036430922,-0.033507414,-0.016082527,-0.01804444,-0.013552691,0.036966577,-0.01510157,-0.011732758,-0.011584324,0.023413887,-0.023568774,0.03781846,0.019812742,-0.007641136,0.010590459,0.0005154863,-0.00523392,-0.021361621,0.01640521,0.015617862,-0.028137967,-0.008570463,0.015398438,0.006511745,0.026279312,0.015617862,-0.0060470817,-0.0014754685,0.012642724,-0.056482453,0.016663356,-0.00073975103,-0.00044731947,0.015127384,0.0018538145,0.0026314808,-0.0015593661,0.013965725,0.0052113323,-0.020329036,0.0011616593,0.0051242076,0.008822156,-0.03286205,-0.007796024,0.006418167,0.018108977,0.005059671,-0.0050403103,0.0023733343,0.016702078,0.0072668237,-0.00027851586,-0.018935045,-0.012655632,-0.0039044656,0.007370082,-0.019709485,-0.0044562537,0.02010961,-0.027002122,-0.026589088,0.042516727,-0.009544967,-0.031752016,0.008415575,0.008718898,0.032061793,0.018922137,-0.010893782,-0.008951229,0.011861831,-0.026421294,-0.015204828,0.01261691,-0.0047724834,0.017115112,0.013888281,-0.012087709,-0.0188576,0.023930179,0.005362993,-0.015475882,-0.00940944,-0.035133738,0.029996622,-0.0118295625,0.008518834,-0.008835063,0.030074066,0.014533647,0.021619769,0.0013907643,0.014727257,-0.016418116,-0.0070022233,0.008467205,0.011603685,-0.052713513,-0.016624633,-0.006363311,0.013010583,0.018935045,-0.004817659,0.010048352,0.0034688434,-0.0025685576,-0.009351357,0.0162116,0.020432295,-0.008112254,-0.04086459,0.004217468,0.029609403,0.030512914,0.0010366195,0.0035269265,0.00047636093,0.010584006,-0.012074802,0.008757619,0.0042949123,-0.0037108557,-0.018922137,0.040064335,-0.022123154,-0.013384895,0.0016779521,0.016250322,-0.010016084,-0.006169701,0.0044820686,-0.030358028,-0.023271905,0.01679243,-0.029454514,-0.01996763,0.001184247,0.0051984247,0.036992393,0.011061577,-0.017812107,0.0058986475,-0.00928682,0.017115112,-0.0103387665,-0.023452608,-0.027286084,0.019451339,0.018147698,0.022161877,-0.0008631773,-0.03714728,0.010603367,0.024394844,0.026124425,-0.014236779,-0.006279413,0.011739211,0.008209058,-0.011268094,0.008822156,0.0047595757,0.011287455,0.012081255,-0.024007624,0.03226831,-0.017050575,0.03892849,0.009764391,-0.022949222,0.0088996,-0.036114693,0.010164518,0.02137453,-0.004262644,-0.011235826,-0.015863102,-0.013397803,-8.476734e-7,0.025775926,0.0067505306,-0.035185367,-0.014314223,-0.029196369,0.0077895704,-0.002473366,-0.020045076,0.015179014,0.00095272186,0.030616174,-0.009351357,-0.007602414,-0.013617227,0.030667802,0.02195536,-0.0010705012,-0.028783333,-0.0087834345,-0.013384895,-0.017683035,-0.03231994,0.02363331,0.0010196787,0.015540418,-0.0067892526,0.01237167,0.015876008,0.008551102,0.0058728326,-0.020729164,-0.0326039,0.020290313,-0.0016174491,-0.0043045925,0.012739529,-0.012190968]; Save and close the file.
Connect to your cluster using mongosh
.
Open mongosh
in a terminal window and connect to your
cluster. For detailed instructions on connecting, see
Connect via mongosh
.
Use the sample_mflix
database.
Run the following command at mongosh
prompt:
use sample_mflix
switched to db sample_mflix
Run the following Atlas Search queries against the embedded_movies
collection.
1 vectorWeight = 1; 2 vectorCutoff = 0.7; 3 numResults = 20; 4 numCandidates = numResults * 10; 5 6 // Execute the vector search 7 vectorResults = db.embedded_movies.aggregate([ 8 { 9 $vectorSearch: { 10 index: "hybrid-vector-search", 11 path: "plot_embedding", 12 queryVector: QUERY_EMBEDDING, 13 numCandidates: numCandidates, 14 limit: numResults 15 } 16 }, 17 { 18 $project: { 19 _id: 1, 20 title: 1, 21 plot: 1, 22 vectorScore: { $meta: "vectorSearchScore" } 23 } 24 }, 25 { 26 $match: { 27 vectorScore: { $gte: vectorCutoff } 28 } 29 } 30 ]).toArray(); 31 32 // Create a map for fast lookup 33 vectorScoresMap = {}; 34 vectorResults.forEach(result => { 35 vectorScoresMap[result._id] = result.vectorScore * vectorWeight; 36 }); 37 38 // Execute the text search with boosting based just on ID 39 textResults = db.embedded_movies.aggregate([ 40 { 41 $search: { 42 index: "hybrid-full-text-search", 43 compound: { 44 should: [ 45 { 46 text: { 47 query: "star wars", 48 path: "plot" 49 } 50 }, 51 ...Object.keys(vectorScoresMap).map(id => ({ 52 equals: { 53 path: "_id", 54 value: id, 55 score: { boost: { value: vectorScoresMap[id] } } 56 } 57 })) 58 ] 59 } 60 } 61 }, 62 { 63 $limit: 20 64 }, 65 { 66 $project: { 67 _id: 1, 68 title: 1, 69 plot: 1, 70 score: { $meta: "searchScore" } 71 } 72 } 73 ]).toArray();
[ { _id: ObjectId('573a139df29313caabcfa90b'), plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...', title: 'Message from Space', score: 4.401333808898926 }, { _id: ObjectId('573a1397f29313caabce6f53'), plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...', title: 'Message from Space', score: 4.401333808898926 }, { _id: ObjectId('573a1398f29313caabce9851'), plot: 'Johnathan Cabot is a champion gymnast. In the tiny, yet savage, country of Parmistan, there is a perfect spot for a "star wars" site. For the US to get this site, they must compete in the ...', title: 'Gymkata', score: 4.284864902496338 }, { _id: ObjectId('573a1394f29313caabcdf65b'), plot: 'A fantastic tale of war, love, family and ambition set in the midst of the Japanese Civil Wars of the sixteenth century.', title: 'Ugetsu', score: 2.858368396759033 }, { _id: ObjectId('573a13a4f29313caabd1137f'), plot: "A producer's film is endangered when his star walks off, so he decides to digitally create an actress to substitute for the star, becoming an overnight sensation that everyone thinks is a real person.", title: 'S1m0ne', score: 2.842216730117798 }, { _id: ObjectId('573a139af29313caabcefe79'), plot: 'An all star baseball player becomes the unhealthy focus of a down on his luck salesman.', title: 'The Fan', score: 2.6598150730133057 }, { _id: ObjectId('573a13a3f29313caabd0c992'), plot: 'The vampire Lestat becomes a rock star whose music wakes up the queen of all vampires.', title: 'Queen of the Damned', score: 2.6598150730133057 }, { _id: ObjectId('573a13a8f29313caabd1da86'), plot: 'During the Napoleonic Wars, a brash British captain pushes his ship and crew to their limits in pursuit of a formidable French war vessel around South America.', title: 'Master and Commander: The Far Side of the World', score: 2.643709897994995 }, { _id: ObjectId('573a139af29313caabcf0e7d'), plot: 'A puppeteer discovers a portal that leads literally into the head of the movie star, John Malkovich.', title: 'Being John Malkovich', score: 2.612804889678955 }, { _id: ObjectId('573a13b6f29313caabd4614f'), plot: 'A former pop star who now writes commercial jingles for a living experiences a mid-life crisis.', title: 'The Good Night', score: 2.612804889678955 }, { _id: ObjectId('573a13cbf29313caabd7fbc9'), plot: 'Bertrand Tavernier is in top form with this gripping, superbly mounted drama set against the savage Catholic/Protestant wars that ripped France apart in the 16th century. Based on a novella...', title: 'The Princess of Montpensier', score: 2.4938809871673584 }, { _id: ObjectId('573a139bf29313caabcf2d8e'), plot: 'Updated version of the classic Rodgers and Hammerstein musical of the classic fairy-tale, with an all-star, multi-racial cast.', title: 'Cinderella', score: 2.44028377532959 }, { _id: ObjectId('573a1399f29313caabcec853'), plot: 'An action movie star researching a role is allowed to tag along with a hardboiled New York policeman, who finds him superficial and irritating.', title: 'The Hard Way', score: 2.325138807296753 }, { _id: ObjectId('573a13b4f29313caabd3f550'), plot: 'A cop, a lawyer, and an assassin cross paths after the murder of a federal witness and the kidnapping of a famous pop star.', title: 'Divergence', score: 2.325138807296753 }, { _id: ObjectId('573a13aff29313caabd2fe20'), plot: 'An intimate story set during the 1860s in which a young Irish woman Sarah and her family find themselves on both sides of the turbulent wars between British and Maori during the British colonization of New Zealand.', title: 'River Queen', score: 2.298485040664673 }, { _id: ObjectId('573a13aef29313caabd2df95'), plot: 'Story of two sisters that grew up in a small Serbian village in the beginning of the 1930s. The village is torn up by wars and years long blood oath. There are no men left in the village. ...', title: 'Tears for Sale', score: 2.268857479095459 }, { _id: ObjectId('573a13b8f29313caabd4d8e1'), plot: "Thomas Michael, Paolo Mancini, Chris Klein and Joe Mantegna star in director Matthiew Klinck's holiday-themed comedy concerning two downsized Easter bunnies whose friendship starts to ...", title: 'Hank and Mike', score: 2.254227876663208 }, { _id: ObjectId('573a139af29313caabcf124d'), plot: 'As the Clone Wars near an end, the Sith Lord Darth Sidious steps out of the shadows, at which time Anakin succumbs to his emotions, becoming Darth Vader and putting his relationships with Obi-Wan and Padme at risk.', title: 'Star Wars: Episode III - Revenge of the Sith', score: 2.2399840354919434 }, { _id: ObjectId('573a13c1f29313caabd633ac'), plot: "Black Dynamite is the greatest African-American action star of the 1970s. When his only brother is killed by The Man it's up to him to find justice.", title: 'Black Dynamite', score: 2.1875147819519043 }, { _id: ObjectId('573a13dbf29313caabdaf598'), plot: "Just as Clint Eastwood's star-making spaghetti Western A Fistful of Dollars was inspired by Akira Kurosawa's Yojimbo, Japanese-Korean filmmaker Sang-il Lee (Villain) has decided to ...", title: 'Unforgiven', score: 2.1875147819519043 } ]
About the Query
The sample query boosts the $search
results based on
$vectorSearch
result scores to return the most relevant
documents. For semantic boosting, you perform the following steps:
Run the
$vectorSearch
query.Use an over request value to specify the number of candidates more than the specified limit to consider. The over request allows you to accomplish the following:
Include a large number and broad pool of documents to consider in the initial search.
Refine scoring computation in subsequent stages.
The query uses the following calculation to determine the number of candidates to consider during the vector search:
numCandidates = limit * over request The results are filtered based on a minimum score threshold (
vectorCutoff
).Scale the vector search score to adjust the influence of the vector search results on the scoring and ranking of documents.
Use the
vectorWeight
parameter to set the weight and multiply the vector search scores by thevectorWeight
. This controls the importance of the vector search results and ensures that only the most semantically relevant documents are considered.Run the
$search
query and boost the score of the documents that match the results from the vector search.
The sample query defines the following variables:
vectorWeight
to add weight to the vector search score, with a lower number providing higher weight.vectorCutoff
to set the minimum vector score for result to be boosted.numResults
to specify the desired number of search resultsnumCandidates
to calculate the number of candidates to consider during the initial search. It calculates the number of candidates by using the following formula:numCandidates = numResults x overRequestFactor
The sample query uses the following pipeline stages to perform a semantic search on the collection and retrieve the reciprocal rank of the documents in the results:
Searches the | |
Searches for movies that contain the term star wars in the
plot field. For the documents in the results that match the
|
Reciprocal Rank Fusion
This section demonstrates how to query the data in the
sample_mflix.embedded_movies
collection for star wars in the
plot_embedding
and title
fields by using the
$vectorSearch
and $search
pipeline stages and
combine each document's scores from both stages to re-sort the documents
in the results. This ensures that documents appearing in both searches
appear at the top of the combined results.
Procedure
Set up the embeddings to use in the query.
Create a file named
query-embeddings.js
.Copy and paste the following embeddings in the file.
STAR_WARS_EMBEDDING=[-0.0031186682172119617, -0.01895737089216709, -0.02120436169207096, -0.031741973012685776, -0.02779036946594715, -0.008749059401452541, -0.02236659824848175, -0.015754763036966324, -0.0026860579382628202, -0.030089015141129494, 0.023709626868367195, 0.0021065538749098778, 0.009756330400705338, 0.003000830300152302, 0.012067890726029873, 0.031741973012685776, 0.026369858533143997, -0.02230202965438366, 0.022560304030776024, -0.030373116955161095, 0.0007251872448250651, 0.012274510227143764, 0.00821313913911581, -0.018634527921676636, 0.012435931712388992, -0.010563439689576626, 0.003832152346149087, -0.03352406993508339, 0.00016797950956970453, -0.024445710703730583, 0.026085754856467247, -0.030528081580996513, -0.020519932731986046, -0.02178548090159893, -0.011538427323102951, -0.012435931712388992, 0.008774886839091778, -0.013443203642964363, 0.01686534471809864, 0.003086383920162916, 0.016813689842820168, 0.018699096515774727, -0.01968054100871086, -0.015367351472377777, -0.02838440053164959, 0.002442311029881239, 0.02252156287431717, -0.02410995401442051, -0.005352745298296213, 0.010518241673707962, -0.002795824781060219, 0.04096238315105438, -0.03582271561026573, -0.013766047544777393, -0.008916937746107578, 0.008529525250196457, -0.007515796925872564, -0.007567451801151037, 0.02903008833527565, -0.01678786240518093, 0.008484327234327793, 0.013778961263597012, -0.023864591494202614, 0.014605440199375153, -0.032749246805906296, 0.0030766986310482025, -0.0002836987259797752, -0.00857472326606512, 0.009782158769667149, 0.0016787862405180931, 0.04147893562912941, 0.01678786240518093, 0.0060081179253757, 0.0076384772546589375, -0.0068313684314489365, -0.010001691989600658, 0.010556982830166817, 0.014140545390546322, -0.006495611276477575, 0.009762787260115147, 0.016968654468655586, -0.01168693508952856, -0.007929036393761635, 0.008723231963813305, 0.021333498880267143, -0.0067151449620723724, -0.013191386125981808, 0.003220363985747099, -0.031664490699768066, 0.004745799582451582, 0.0010879826731979847, -0.002786139491945505, 0.009439944289624691, 0.023438438773155212, -0.020946087315678596, 0.019964642822742462, -0.009013790637254715, 0.03329162299633026, 0.005213922820985317, -0.03520285710692406, 0.0029572464991360903, 0.005326917860656977, -0.01487662922590971, -0.02368379943072796, -0.009530340321362019, 0.009427030570805073, 0.016852430999279022, 0.007922579534351826, 0.018298769369721413, -0.004077513702213764, -0.011428659781813622, 0.021617600694298744, 0.0052558924071490765, -0.03925777226686478, -0.016813689842820168, -0.022056668996810913, -0.0005129176424816251, -0.009581995196640491, 0.007554538082331419, -0.02910757064819336, 0.02670561522245407, 0.016981568187475204, 0.016452105715870857, -0.0121582867577672, 0.028771813958883286, 0.021966272965073586, -0.01579350419342518, 0.0008252687403000891, -0.01977093704044819, -0.01716236025094986, 0.03561609610915184, 0.012649009004235268, 0.02396790124475956, -0.002277660882100463, -0.029985705390572548, 0.022211633622646332, 0.005846695974469185, 0.01658124290406704, -0.01615508832037449, -0.010724861174821854, 0.0043390169739723206, 0.025349672883749008, -0.007916122674942017, -0.001988715957850218, -0.006288991775363684, 0.009943580254912376, 0.0122293122112751, 0.030089015141129494, 0.010001691989600658, -0.020661983639001846, 0.01766599714756012, -0.02310268208384514, 0.021553032100200653, 0.004639261402189732, 0.007786985486745834, 0.005795041099190712, -0.004678002558648586, -0.0054140854626894, -0.0014455318450927734, -0.0068765669129788876, -0.005443141330033541, 0.004881393630057573, 0.010853998363018036, -0.017833875492215157, 0.021746737882494926, 0.021604686975479126, 0.017627255991101265, 0.01169339194893837, -0.018298769369721413, -0.0026715300045907497, -0.015264040790498257, 0.03055390901863575, -0.018156718462705612, 0.028539367020130157, 0.00013508982374332845, 0.024342400953173637, 0.009853184223175049, 0.019796764478087425, -0.032904211431741714, -0.02742878533899784, -0.023722540587186813, 0.011900011450052261, 0.021191447973251343, 0.02794533409178257, -0.0039128633216023445, 0.0071025569923222065, 0.006124341394752264, 0.012971851974725723, 0.017859702929854393, -0.011958123184740543, 0.00025544993695802987, 0.023503007367253304, 0.01067320629954338, 0.0024003414437174797, -0.6789528131484985, -0.026163237169384956, 0.01940935105085373, -0.00869094766676426, 0.00973695982247591, 0.01730441115796566, 0.022689441218972206, 0.017317326739430428, -0.0060920570977032185, -0.01371439266949892, -0.014385906979441643, 0.00580795481801033, 0.011280152015388012, -0.012054977007210255, -0.011015420779585838, -0.007715960033237934, 0.01838916540145874, -0.012100175023078918, 0.008342276327311993, -0.0008732916903682053, -0.026292376220226288, 0.02330930158495903, 0.003954832907766104, -0.015160731039941311, 0.023490093648433685, 0.013481944799423218, 0.0002556517138145864, -0.009071902371942997, -0.028177781030535698, 0.026292376220226288, -0.020545760169625282, 0.0201325211673975, 0.004497210029512644, 0.0043906718492507935, 0.044474922120571136, 0.002279275096952915, -0.031096287071704865, 0.037165746092796326, 0.024716898798942566, 0.020610328763723373, -0.0121582867577672, -0.0034059989266097546, 0.006030716933310032, 0.008129199966788292, -0.015457747504115105, 0.017898444086313248, 0.027093026787042618, -0.003816010197624564, -0.014127631671726704, -0.0016949283890426159, 0.0030589422676712275, -0.002372899791225791, 0.005575507413595915, 0.0029427185654640198, 0.010163113474845886, 0.007386659272015095, 0.025724170729517937, -0.011712762527167797, 0.0024035698734223843, 0.018414992839097977, 0.00019925498054362833, 0.015728935599327087, -0.005420542322099209, -0.0011162314331158996, -0.006566637195646763, 0.037165746092796326, -0.016090519726276398, 0.016594156622886658, 0.000506460783071816, -0.018866974860429764, 0.013036420568823814, 0.010808800347149372, -0.002661844715476036, -0.0037127004470676184, 0.01176441740244627, 0.03809553384780884, 0.020649069920182228, -6.841507911303779e-06, -0.0067345155403018, 0.024342400953173637, 0.008555352687835693, 0.0005334988818503916, -0.02439405582845211, 0.008400388062000275, 0.023787109181284904, 0.0026715300045907497, -0.02851353958249092, 0.014463389292359352, 0.012668379582464695, 0.004371301271021366, 0.01563853956758976, 0.0034834814723581076, -0.013623995706439018, -0.007870924659073353, 0.009724046103656292, -0.011409289203584194, -0.033988963812589645, 0.001977416453883052, 0.01584515906870365, -0.030321462079882622, -0.0025068798568099737, 0.0136110819876194, -0.004849109333008528, -0.0025230220053344965, 0.006669946946203709, 0.0022938030306249857, 0.008871739730238914, 0.020029211416840553, 0.03396313637495041, -0.042666997760534286, 0.007231694646179676, -0.010124372318387032, -0.022986458614468575, -0.012216398492455482, 0.008452042937278748, -0.021979186683893204, 0.036235954612493515, 0.0005258313613012433, 0.012610267847776413, -0.02462650276720524, 0.023257646709680557, -0.003803096478804946, 0.004232478328049183, -0.007560994941741228, 0.002114624949172139, 0.002708656946197152, 0.004061371553689241, -0.027532095089554787, -0.003919320181012154, -0.005485111381858587, -0.002684443723410368, 0.020532846450805664, 0.015974296256899834, -0.008180854842066765, 0.007089643273502588, -0.0016691009514033794, -0.004122711718082428, -0.008445586077868938, 0.0040968842804431915, -0.030683046206831932, -0.02338678389787674, 0.006895937491208315, -0.006799084134399891, 0.01209371816366911, 0.0041549960151314735, -0.02585330791771412, -0.0015867758775129914, -0.005820868536829948, -0.009853184223175049, 0.0002175158151658252, -0.011086446233093739, -0.001430196687579155, -0.017898444086313248, 0.005246207118034363, 0.005717558320611715, -0.0032235924154520035, -0.022689441218972206, -0.00850369781255722, -0.00048426527064293623, -0.01868618279695511, 0.005088013596832752, 0.0007679639966227114, -0.002142066601663828, -0.008949222043156624, 0.017911357805132866, -0.020661983639001846, 0.0014818516792729497, 0.011163928546011448, -0.026176150888204575, -0.016619984060525894, 0.02851353958249092, -0.0038547515869140625, -0.004277676343917847, 0.02851353958249092, -0.024742726236581802, 0.026679787784814835, -0.023696713149547577, -0.023774195462465286, 0.007696589455008507, 0.001584354555234313, 0.0005024251877330244, 0.0038063249085098505, -0.013100989162921906, 0.01379187498241663, 0.01947391964495182, 0.007709503173828125, 0.012106631882488728, 0.009465771727263927, 0.004313189070671797, 0.0025230220053344965, -0.01840207912027836, 0.015470661222934723, -0.014295510947704315, 0.0035835630260407925, -0.006318047642707825, -0.01614217460155487, -0.007870924659073353, 0.009439944289624691, 0.023205991834402084, 0.020959001034498215, 0.03476379066705704, -0.013443203642964363, 0.0202745720744133, -0.029133398085832596, 0.008968592621386051, -0.04801328480243683, 0.003344658762216568, -0.020649069920182228, 0.016684552654623985, -8.43428642838262e-05, 0.01962888613343239, 0.013456117361783981, 0.007335004396736622, -0.015987209975719452, 0.021320585161447525, 0.03494458273053169, -0.005404400173574686, 0.0004991967580281198, -0.021695083007216454, 0.00789675209671259, -0.003451197175309062, -0.014579612761735916, 0.009084816090762615, 0.0014463389525189996, -0.024264918640255928, 0.007909665815532207, 0.019887160509824753, 0.016981568187475204, 0.016981568187475204, -0.02035205438733101, -0.00836164690554142, -0.012119545601308346, -0.005837010685354471, 0.026176150888204575, -0.015251127071678638, 0.015406092628836632, 0.010899197310209274, -0.027816196903586388, 0.03104463219642639, -0.002690900582820177, -0.006556951440870762, 0.002949175424873829, 0.03902532160282135, 0.01285562850534916, -0.0005778899067081511, 0.006999247241765261, 0.042744480073451996, -0.008916937746107578, -0.010615094564855099, -0.0029637033585458994, -0.010330991819500923, -0.016710380092263222, -0.0048652514815330505, 0.01487662922590971, 0.005459283944219351, -0.031896937638521194, 0.015509402379393578, 0.0024390826001763344, 0.03946439176797867, 0.02005503885447979, 0.014566699042916298, 0.013778961263597012, 0.009142927825450897, -0.013572340831160545, -0.006046859081834555, 0.013288239017128944, 0.0016513445880264044, 0.025904962792992592, 0.0030169726815074682, 0.007380202412605286, 0.00019542120571713895, -8.499863906763494e-05, 0.008135656826198101, -0.015832245349884033, -0.0011622366728261113, -0.01270712073892355, 0.009149384684860706, 0.0021323813125491142, 0.0012477901764214039, 0.013443203642964363, 0.011047705076634884, -0.031457871198654175, 0.01020831149071455, 0.011796701699495316, -0.010040433146059513, -0.022702354937791824, -0.019383523613214493, -0.02237951196730137, 0.0027651546988636255, 0.028565194457769394, -0.021953359246253967, 0.021101051941514015, 0.013404462486505508, -0.004849109333008528, -0.03801805153489113, 0.006747429259121418, 0.01331406645476818, -0.015870986506342888, 0.02259904518723488, 0.01100896392017603, -0.0021275386679917574, 0.012416561134159565, -0.014347165822982788, -0.0205586738884449, 0.009872554801404476, -0.00984672736376524, 0.005475426092743874, -0.02425200492143631, 0.014915370382368565, -0.018156718462705612, -0.005940320435911417, -0.006702231243252754, -0.030786357820034027, -0.004022629931569099, 0.0027651546988636255, 0.0026231035590171814, -0.017756393179297447, -0.006159854121506214, 0.04819408059120178, 0.010156656615436077, 0.009485142305493355, -0.014902456663548946, -0.00390963489189744, 0.0020581274293363094, 0.07474473118782043, 0.0007171161705628037, 0.012590897269546986, 0.011448030360043049, 0.002130767097696662, -0.009962950833141804, -0.024523193016648293, -0.0022066354285925627, -0.01423094142228365, -0.017188187688589096, -0.0016473090508952737, -0.007083186414092779, 0.01948683336377144, 0.010356820188462734, -0.0013228512834757566, 0.012423017993569374, 0.018260028213262558, -0.005259120836853981, 0.012720034457743168, 0.0010468200780451298, -0.016736207529902458, -0.011867727153003216, 0.019383523613214493, -0.0053721158765256405, 0.028565194457769394, -0.030321462079882622, 0.010892740450799465, 0.011125187389552593, -0.009491599164903164, -0.03703660890460014, -0.023980814963579178, -0.00635033193975687, -0.0205586738884449, 0.013946839608252048, 0.011738589964807034, -0.006182453129440546, 0.004736114293336868, 0.015354436822235584, 0.01629714109003544, -0.021410981193184853, 0.0013293081428855658, 0.020184176042675972, -0.0009967793012037873, -0.013520685955882072, 0.004510123748332262, -0.008103372529149055, -0.01184189971536398, 0.027480440214276314, -0.005552908405661583, -0.03380817174911499, 0.01851830445230007, -0.011557797901332378, -0.01299122255295515, -0.00025161614757962525, -0.00035351363476365805, 0.011480315588414669, -0.0049911607056856155, -0.012726491317152977, -0.01948683336377144, -0.005743386223912239, -0.011131644248962402, -0.030243979766964912, 0.01853121817111969, 0.007380202412605286, -0.007380202412605286, -0.013100989162921906, -0.015444833785295486, -0.023038113489747047, -0.00796132069081068, -0.0011041248217225075, -0.008387474343180656, 0.005617476999759674, 0.001272003399208188, 0.006947592366486788, 0.01912524923682213, -0.020403709262609482, 0.014114717952907085, 0.005452827084809542, 0.013817702420055866, 0.02093317359685898, -0.011770874261856079, 0.0008531139465048909, -0.008729688823223114, -0.018776578828692436, 0.011525513604283333, 0.0004927398986183107, 0.026886407285928726, -0.004658631980419159, 0.002468138700351119, 0.0025343215093016624, 0.019964642822742462, -0.0016529588028788567, 0.003661045338958502, -0.0004991967580281198, 0.015509402379393578, 0.0050718714483082294, 0.007903208956122398, -0.000564976129680872, 0.017201101407408714, 0.00665703322738409, -0.004729657433927059, -0.01570310816168785, 0.01129306573420763, 0.0057401577942073345, -0.0024939661379903555, -0.0038353807758539915, 0.0092333247885108, 0.014088890515267849, -0.014889542944729328, -0.010046890005469322, -0.007948406971991062, -0.02895260602235794, 0.004839424043893814, -0.009575538337230682, 0.004800682887434959, 0.033420760184526443, -0.0008345504757016897, 0.006453641690313816, 0.0024229404516518116, -0.022495735436677933, 0.004058143123984337, -0.040265042334795, -0.006582779344171286, 0.023657971993088722, -0.005623933859169483, 0.0007853168062865734, 0.011751503683626652, -0.0193189550191164, -0.0030298864003270864, 0.003221978200599551, -0.02462650276720524, 0.013688565231859684, 0.009433487430214882, 0.019590144976973534, -0.040265042334795, -0.007212324067950249, -0.01766599714756012, 0.016736207529902458, -0.004626347683370113, 0.005288176704198122, -0.03672667592763901, -0.013339893892407417, 0.018079236149787903, -0.024639416486024857, 0.0034059989266097546, -0.026473168283700943, -0.010447216220200062, -0.0023051027674227953, -0.007509340066462755, 0.00514289690181613, -0.022921890020370483, 0.008807171136140823, -0.0011347949039191008, -0.021979186683893204, -0.004435869865119457, -0.043674271553754807, -0.012177657335996628, -0.03602933511137962, 0.02686057984828949, 0.020093780010938644, 0.036080989986658096, -0.00761910667642951, 0.02418743632733822, -0.014708749949932098, -0.004051686264574528, 0.010963765904307365, 0.00803880300372839, 0.016400450840592384, 0.0017191417282447219, 0.03422141075134277, 0.029443327337503433, -0.0008563424344174564, 0.0093753756955266, 0.006343875080347061, 0.02851353958249092, 0.018079236149787903, 0.0015044508036226034, 0.008329362608492374, -0.008251880295574665, -0.0037062435876578093, -0.005530309397727251, 0.013856443576514721, -0.008820084854960442, -0.0058273253962397575, -0.013985580764710903, -0.007302720099687576, 0.00897504948079586, 0.013766047544777393, 0.0007780528394505382, 0.006347103510051966, 0.03662336617708206, -0.02258613146841526, 0.018699096515774727, -0.015909727662801743, 0.021462636068463326, -0.01628422737121582, 0.00016021108604036272, -0.009478685446083546, 0.009142927825450897, -0.006253478582948446, 0.018053408712148666, -0.017498118802905083, -0.027996988967061043, 0.017252756282687187, -0.002154980320483446, 0.03600350767374039, -0.011189755983650684, 0.0019031624542549253, 0.0002861200482584536, -0.022482821717858315, -0.006582779344171286, -0.019577231258153915, -0.011848356574773788, -0.0447331964969635, -0.016852430999279022, 0.0002580730360932648, -0.0042357067577540874, 0.023800022900104523, -0.01840207912027836, -0.015083248727023602, 0.013804788701236248, 0.006198595277965069, 0.025892049074172974, 0.002644088352099061, 0.03742402046918869, 0.007380202412605286, -0.010686120018362999, -0.0040290867909789085, -0.005485111381858587, -0.02179839462041855, 0.0029136626981198788, 0.007134841755032539, 0.015264040790498257, -0.025349672883749008, -0.003138038795441389, 0.004174366593360901, -0.016736207529902458, -0.03907697647809982, -0.02810029871761799, 0.007173582911491394, 0.0005157425184734166, 0.029443327337503433, -0.027971161529421806, -0.022831492125988007, -0.03293003886938095, 0.007696589455008507, -0.01656832918524742, 0.0025633773766458035, -0.024884777143597603, -0.039774321019649506, -0.01585807278752327, -0.007502883207052946, -0.009962950833141804, 0.019938815385103226, -0.010983136482536793, -0.025788739323616028, 0.010427845641970634, -0.010105001740157604, 0.007070272695273161, -0.016594156622886658, -0.030579736456274986, 0.02316725067794323, -0.0027812968473881483, 0.0005447984440252185, 0.01868618279695511, 0.008458499796688557, -0.022134151309728622, -0.0006844282615929842, 0.016193829476833344, 0.022973544895648956, -0.014760404825210571, -0.016477933153510094, -0.0030815412756055593, 0.0050492724403738976, 0.0199904702603817, -0.0029992160852998495, -0.011964580044150352, -0.017678910866379738, -0.012474672868847847, -0.0035997051745653152, 0.006611835211515427, -0.000777245732024312, -0.021707996726036072, -0.020816950127482414, -0.005459283944219351, -0.020816950127482414, -0.01643919199705124, -0.0058273253962397575, 0.008716775104403496, -0.031380388885736465, -0.006799084134399891, -0.0038902643136680126, -0.030967149883508682, 0.006014574784785509, -0.0005460091051645577, -0.010053346864879131, 0.006966962944716215, 0.04003259539604187, -0.02758374996483326, -0.010163113474845886, -0.018298769369721413, 0.013572340831160545, -0.032620109617710114, 0.0018240658100694418, -0.005530309397727251, -0.023580489680171013, 0.02533675916492939, -0.020507019013166428, -0.019241472706198692, 0.0006154204602353275, 0.016452105715870857, 0.0006081564351916313, 0.012403647415339947, 0.008936308324337006, 0.024587761610746384, 0.023761281743645668, -0.010105001740157604, -0.02519470825791359, -0.01495411153882742, 0.011790244840085506, -0.0015230142744258046, -0.0005605370388366282, 0.010841084644198418, -0.030605563893914223, 0.0175110325217247, -0.004920135252177715, 0.011047705076634884, -0.005714329890906811, -0.02910757064819336, -0.010240595787763596, -0.019732195883989334, 0.04227958619594574, -0.015535229817032814, -0.011331806890666485, -0.032181039452552795, 0.0034544256050139666, -0.0073156338185071945, 0.03497041016817093, -0.002472981344908476, -0.00851015467196703, 0.0033478871919214725, 0.03349824249744415, 0.01897028461098671, 0.0007421365007758141, 0.005665903445333242, 0.003396313637495041, 0.009601365774869919, -0.018505390733480453, -0.0120872613042593, -0.0049330489709973335, 0.001736898091621697, 0.023038113489747047, 0.0058563812635838985, -0.016258399933576584, -0.0067797135561704636, 0.009175212122499943, -0.01939643733203411, -0.0008163905004039407, -0.003887035883963108, 0.013339893892407417, 0.005627162288874388, -0.0009903224417939782, 9.322106052422896e-05, 0.017756393179297447, -0.010040433146059513, -0.010040433146059513, -0.0036997864954173565, 0.01556105725467205, 0.023541748523712158, -0.010033976286649704, 0.0107571454718709, 0.00712838489562273, -0.02266361378133297, 0.002879764186218381, 0.017201101407408714, 0.006188909988850355, 0.013817702420055866, -0.007496426347643137, 0.00487170834094286, -0.010473043657839298, -0.01918981783092022, -0.003796639619395137, -0.005698187742382288, 0.017640169709920883, 0.014321338385343552, -0.027325473725795746, 0.0012671607546508312, 0.0009628807893022895, 0.004306732211261988, -0.01643919199705124, -0.002137223957106471, 0.019577231258153915, -0.02142389491200447, 0.0013381863245740533, 0.006082371808588505, -0.02179839462041855, -0.014566699042916298, -0.02946915477514267, 0.010105001740157604, 0.007761158049106598, -0.012054977007210255, 0.02112687937915325, 0.013088075444102287, -0.0036061620339751244, -0.01082171406596899, -0.01292019709944725, 0.0039128633216023445, -0.013740220107138157, -0.00183697952888906, -0.01873783767223358, 0.007935493253171444, -0.013049334287643433, 0.004232478328049183, -0.04589543491601944, 0.03187111020088196, -0.019306041300296783, 0.00821959599852562, -0.02634403109550476, 0.014179286547005177, 0.00425184890627861, -0.005872523412108421, 0.011628823354840279, 0.009058988653123379, 0.014992852695286274, -0.013494858518242836, 0.00022074424487072974, -0.0007494004676118493, -0.0025246362201869488, 0.009078359231352806, 0.020649069920182228, -0.006185681559145451, -0.012054977007210255, 0.0017401265213266015, 0.002737713046371937, -0.004603748209774494, 0.0369332991540432, 0.22542224824428558, -0.011422202922403812, 0.0031412672251462936, 0.04540470987558365, -0.00017544526781421155, 0.036313436925411224, 0.01651667430996895, 0.0033059176057577133, -0.025375500321388245, 0.009510969743132591, -0.026963889598846436, 0.012371363118290901, 0.0136110819876194, 0.0003603740769904107, 0.0025391641538590193, -0.028539367020130157, -0.01636170968413353, -0.017343154177069664, -0.037320710718631744, -0.019732195883989334, -0.001901548239402473, -0.0023922703694552183, -0.016129260882735252, -0.019241472706198692, 0.006818454712629318, -0.011809615418314934, -0.002891063690185547, -0.00868449080735445, 0.01895737089216709, 0.02779036946594715, -0.008516611531376839, -0.0021049396600574255, 0.00421633617952466, -0.005449598655104637, -0.016619984060525894, 0.008568266406655312, -0.004855566192418337, -0.001212277333252132, 0.0036061620339751244, 0.0060081179253757, -0.01955140382051468, 0.01053115539252758, -0.006205052137374878, 0.030243979766964912, -0.012616724707186222, 0.024923518300056458, -0.009459314867854118, 0.01270066387951374, 0.015070335008203983, 0.01477331854403019, -0.027893679216504097, -0.0205586738884449, 0.033911481499671936, 0.06141774728894234, -0.01562562584877014, 0.010214768350124359, -0.003774040611460805, 0.0035415932070463896, -0.007367288693785667, 0.0003297039365861565, -0.004071056842803955, 0.015483574941754341, -0.02549172379076481, 0.017717652022838593, -0.012145373038947582, 0.009724046103656292, -0.03858625516295433, 0.019925901666283607, 0.016839517280459404, -0.013585254549980164, 0.004613433964550495, -0.03055390901863575, -0.015987209975719452, -0.016852430999279022, -0.032981693744659424, -0.016452105715870857, 0.029004260897636414, 0.0039128633216023445, -0.010402018204331398, 0.01714944653213024, 0.011396375484764576, -0.0366491936147213, -0.01006626058369875, -0.021088138222694397, -0.025091396644711494, -0.04698018729686737, 0.016025951132178307, -0.002561763161793351, -0.009801529347896576, 0.02395498752593994, -0.01324949786067009, -0.006947592366486788, -0.015083248727023602, -0.020080866292119026, 0.01752394624054432, -0.01136409118771553, 0.009336634539067745, 0.007218780927360058, -0.02657647803425789, -0.007922579534351826, -0.024355314671993256, -0.01401140820235014, 0.009601365774869919, 0.005791812669485807, -0.01621965877711773, 0.020222917199134827, 0.0011033177142962813, 0.01270066387951374, -0.012358449399471283, 0.0050492724403738976, 0.012061433866620064, -0.019422264769673347, 0.010718404315412045, 0.0071412986144423485, -0.019964642822742462, 0.01845373585820198, 0.00273287040181458, 0.00789029523730278, 0.02706719934940338, -0.03187111020088196, 0.0015916185220703483, 0.01129306573420763, 0.012332621961832047, -0.005724015180021524, 0.0046166623942554, -0.024729812517762184, -0.00754808122292161, 0.009401203133165836, 0.002666687360033393, -0.029882395640015602, -0.007786985486745834, -0.017110705375671387, 0.018221287056803703, -0.011047705076634884, -0.00693467864766717, 0.008025889284908772, 3.1606505217496306e-06, 0.005126754753291607, -0.00434547383338213, 0.01636170968413353, -0.011157471686601639, 0.004868479911237955, -0.005930635146796703, 0.020816950127482414, 0.02250864915549755, -0.015354436822235584, 0.008845912292599678, 0.009078359231352806, 0.0031945365481078625, -0.013727306388318539, -0.010156656615436077, -0.015431920066475868, 0.007625563535839319, -0.026318203657865524, 0.012803973630070686, -0.02634403109550476, -0.03680415824055672, -0.028074471279978752, -0.01642627827823162, 0.02939167246222496, -0.0308380126953125, 0.010427845641970634, 0.025168880820274353, 0.0026925147976726294, -0.024355314671993256, -0.03063139133155346, -0.16612236201763153, 0.03207772970199585, 0.02324473299086094, -0.004665088839828968, 0.01838916540145874, 0.0037320710252970457, 0.011725676245987415, 0.0017191417282447219, 0.020093780010938644, 0.0014745877124369144, 0.021669255569577217, 0.002995987655594945, -0.03489292785525322, 0.009749873541295528, 0.02642151340842247, 0.01423094142228365, 0.0018095378763973713, 0.013094532303512096, 0.0018402079585939646, 0.008258337154984474, 0.024006642401218414, -0.020829863846302032, -0.005833782255649567, -0.01169339194893837, -0.0030637849122285843, -0.012061433866620064, 0.007496426347643137, 0.02258613146841526, -0.0023535292129963636, 0.005446370225399733, -0.017795134335756302, -0.009620736353099346, 0.03300752118229866, 0.0050492724403738976, 0.01093148160725832, 0.01299122255295515, -0.01636170968413353, -0.02208249643445015, 0.0004903185763396323, 0.029081743210554123, 0.0215142909437418, 0.007870924659073353, 0.029856568202376366, -0.0015149432001635432, 0.004787769168615341, 0.02026165835559368, 0.005717558320611715, 0.0007998447981663048, 0.013830616138875484, -0.01593555510044098, -0.006366474088281393, -0.019809678196907043, -0.008987963199615479, -0.010879825800657272, 0.009504512883722782, 0.02381293661892414, 0.014579612761735916, 0.0069863335229456425, -0.0016658725216984749, -0.022986458614468575, -0.008542438969016075, -0.018414992839097977, 0.005278491415083408, -0.017911357805132866, -0.01607760600745678, -0.02048119157552719, -0.000788948847912252, -0.007218780927360058, -0.010356820188462734, 0.012791059911251068, 0.0002893485070671886, -0.00037712158518843353, -0.0018030810169875622, 0.0028297232929617167, 0.016684552654623985, 0.00010724458115873858, -0.013843529857695103, 0.030373116955161095, -0.01277814619243145, -0.005594877991825342, -0.022185806185007095, 0.03305917605757713, 0.011099359951913357, -0.0009564238716848195, 0.007070272695273161, 0.01146740186959505, -0.010544069111347198, -0.007703046314418316, -0.02324473299086094, -0.015406092628836632, 0.020545760169625282, -0.012048520147800446, -0.003622304182499647, -0.0015173645224422216, 0.01263609528541565, 0.02657647803425789, 0.003825695486739278, -0.009795072488486767, 0.007406030315905809, 0.004012944642454386, -0.001643273513764143, -0.007263978943228722, -0.0003640060604084283, 0.030863840132951736, 0.02128184400498867, 0.024381142109632492, 0.01692991331219673, 0.01115101482719183, 0.019138162955641747, 0.010176027193665504, -0.004113026428967714, -0.0005782934604212642, 0.014463389292359352, 0.017356067895889282, 0.004038772080093622, 0.02497517317533493, 0.005959691014140844, -0.011531970463693142, 0.033782344311475754, 0.0019693453796207905, 0.04886559396982193, -0.0007106592529453337, -0.021088138222694397, -0.0019289900083094835, -0.010098544880747795, -0.007360831834375858, -0.06916598975658417, -0.022043755277991295, 0.02316725067794323, -0.0001706026232568547, -0.014540871605277061, 0.012177657335996628, -0.00829062145203352, 0.005853152833878994, -0.014166372828185558, 0.009614279493689537, 0.000888626731466502, -0.04677356779575348, -0.0006751464679837227, -0.012171200476586819, 0.00891048088669777, -0.0060113463550806046, -0.010569896548986435, -0.001041977433487773, -0.008800714276731014, 0.015083248727023602, 0.0039709750562906265, 0.011854813434183598, 0.01136409118771553, 0.0065763224847614765, -0.011661107651889324, -0.0017885530833154917, -0.021591773256659508, 0.03517702966928482, 0.009472228586673737, 0.012209941633045673, 0.0012873384403064847, 0.010892740450799465, -0.0036126188933849335, -0.019228558987379074, -0.021604686975479126, 0.001825680024921894, -0.021320585161447525, -0.012597354128956795, 0.0034350550267845392, -0.0569237656891346, 0.008568266406655312, 0.025065569207072258, -0.013184929266571999, -0.03205190226435661, -0.014592526480555534, -0.009536797180771828, 0.010724861174821854, 0.011099359951913357, 0.016684552654623985, -0.022134151309728622, -0.0344538576900959, -0.023787109181284904, -0.014192200265824795, 0.0024116409476846457, 0.02409704029560089, -0.00658600777387619, 0.01678786240518093, -0.008167941123247147, -0.002761926269158721, -0.0005762756918556988, -0.0016166388522833586, 0.002079112222418189, -0.0033059176057577133, 0.017614342272281647, 0.0005762756918556988, 0.004619890823960304, -0.006440727971494198, -0.02142389491200447, 0.01053761225193739, -0.019202731549739838, -0.020080866292119026, 0.00340277049690485, -0.03497041016817093, -0.003609390463680029, -0.033549897372722626, -0.016116347163915634, -0.018130891025066376, -0.0136110819876194, 0.03698495402932167, -0.015186558477580547, -0.011777331121265888, -0.011654650792479515, 0.02337387017905712, -0.02359340339899063, 0.037888914346694946, 0.01983550563454628, -0.007612649817019701, 0.010615094564855099, 0.0005395521875470877, -0.005181638523936272, -0.02134641259908676, 0.01642627827823162, 0.015664367005228996, -0.02815195359289646, -0.008535982109606266, 0.015354436822235584, 0.006456870120018721, 0.02627946250140667, 0.015651453286409378, -0.0061211129650473595, -0.0014794303569942713, 0.012552155181765556, -0.056510526686906815, 0.016671638935804367, -0.0006678825011476874, -0.0004168716841377318, 0.015199472196400166, 0.0017788676777854562, 0.0025407783687114716, -0.001502029481343925, 0.013959753327071667, 0.005184866953641176, -0.020313313230872154, 0.001076683052815497, 0.005120297893881798, 0.008813627995550632, -0.032904211431741714, -0.007774071767926216, 0.00646332697942853, 0.018117977306246758, 0.00502990186214447, -0.005055729299783707, 0.002456839196383953, 0.016762034967541695, 0.007289806380867958, -0.0002102518337778747, -0.01895737089216709, -0.012655465863645077, -0.003922548610717058, 0.007399572990834713, -0.019667627289891243, -0.004455240443348885, 0.020106693729758263, -0.026912234723567963, -0.026473168283700943, 0.04251203313469887, -0.009530340321362019, -0.031664490699768066, 0.008342276327311993, 0.008723231963813305, 0.03202607482671738, 0.019009025767445564, -0.010905654169619083, -0.00897504948079586, 0.01183544285595417, -0.026473168283700943, -0.015264040790498257, 0.012687750160694122, -0.004713515285402536, 0.01709779165685177, 0.01379187498241663, -0.012080804444849491, -0.018892802298069, 0.024019557982683182, 0.005407628603279591, -0.015444833785295486, -0.009394746273756027, -0.03509954735636711, 0.03003736026585102, -0.01184189971536398, 0.008477870374917984, -0.008807171136140823, 0.03003736026585102, 0.014540871605277061, 0.021604686975479126, 0.001436653663404286, 0.014734577387571335, -0.016452105715870857, -0.007037988398224115, 0.008490784093737602, 0.011525513604283333, -0.05279137194156647, -0.016684552654623985, -0.0063632456585764885, 0.01299122255295515, 0.018983198329806328, -0.0048652514815330505, 0.010072717443108559, 0.003396313637495041, -0.0025214077904820442, -0.009349548257887363, 0.016245486214756966, 0.020429536700248718, -0.008116286247968674, -0.04091072827577591, 0.004190508741885424, 0.029649948701262474, 0.03047642670571804, 0.0010113072348758578, 0.0035351363476365805, 0.0004822475020773709, 0.01060218084603548, -0.01209371816366911, 0.008787800557911396, 0.004261534195393324, -0.0036836443468928337, -0.01895737089216709, 0.04011007770895958, -0.022056668996810913, -0.013301152735948563, 0.0017401265213266015, 0.016335882246494293, -0.010046890005469322, -0.006101742386817932, 0.00448752474039793, -0.030347289517521858, -0.023283474147319794, 0.016710380092263222, -0.029494982212781906, -0.019951729103922844, 0.0011735361767932773, 0.005188095383346081, 0.03706243634223938, 0.010970222763717175, -0.017795134335756302, 0.0058854371309280396, -0.009349548257887363, 0.017175273969769478, -0.010311621241271496, -0.023490093648433685, -0.027325473725795746, 0.01947391964495182, 0.01810506358742714, 0.022095410153269768, -0.000895083649083972, -0.03706243634223938, 0.010621551424264908, 0.0244586244225502, 0.026189064607024193, -0.014243856072425842, -0.006259935442358255, 0.011790244840085506, 0.008226052857935429, -0.011280152015388012, 0.008852369152009487, 0.0047490280121564865, 0.011286608874797821, 0.012126002460718155, -0.02395498752593994, 0.03220686689019203, -0.01702030934393406, 0.03897366672754288, 0.00974341668188572, -0.023051027208566666, 0.00890402402728796, -0.03610681742429733, 0.01013082917779684, 0.02134641259908676, -0.0042357067577540874, -0.011254324577748775, -0.015909727662801743, -0.013301152735948563, 5.8578439166012686e-06, 0.025814566761255264, 0.006682860665023327, -0.03517702966928482, -0.014360079541802406, -0.02923670783638954, 0.007780528627336025, -0.0023987272288650274, -0.02004212513566017, 0.015173644758760929, 0.001025028177537024, 0.030605563893914223, -0.009388289414346218, -0.00761910667642951, -0.0136110819876194, 0.030605563893914223, 0.021953359246253967, -0.0010088859125971794, -0.02882346883416176, -0.008794257417321205, -0.013352807611227036, -0.017678910866379738, -0.032258521765470505, 0.023567575961351395, 0.001000814838334918, 0.01549648866057396, -0.006792627274990082, 0.012358449399471283, 0.01593555510044098, 0.008561809547245502, 0.0058789802715182304, -0.020752381533384323, -0.03256845474243164, 0.020326226949691772, -0.0016150246374309063, -0.004316417500376701, 0.01270712073892355, -0.012190571054816246]; Save and close the file.
Connect to your cluster using mongosh
.
Open mongosh
in a terminal window and connect to your
cluster. For detailed instructions on connecting, see
Connect via mongosh
.
Use the sample_mflix
database.
Run the following command at mongosh
prompt:
use sample_mflix
switched to db sample_mflix
Load the embeddings to use in the query.
Run the following command to load the embeddings after replacing
<path-to-file>
with the absolute path to the embeddings.js
file:
load('<path-to-query>/embeddings.js');
To verify that the embeddings loaded successfully, run the following command:
STAR_WARS_EMBEDDING.length
1536
Run the following Atlas Search queries against the embedded_movies
collection.
1 db.embedded_movies.aggregate([ 2 { 3 $rankFusion: { 4 input: { 5 pipelines: { 6 vectorPipeline: [ 7 { 8 "$vectorSearch": { 9 "index": "hybrid-vector-search", 10 "path": "plot_embedding", 11 "queryVector": STAR_WARS_EMBEDDING, 12 "numCandidates": 100, 13 "limit": 20 14 } 15 } 16 ], 17 fullTextPipeline: [ 18 { 19 "$search": { 20 "index": "hybrid-full-text-search", 21 "phrase": { 22 "query": "star wars", 23 "path": "title" 24 } 25 } 26 }, 27 { "$limit": 20 } 28 ] 29 } 30 }, 31 combination: { 32 weights: { 33 vectorPipeline: 0.7, 34 fullTextPipeline: 0.3 35 } 36 }, 37 "scoreDetails": true 38 } 39 }, 40 { 41 "$project": { 42 _id: 1, 43 title: 1, 44 plot: 1, 45 scoreDetails: {"$meta": "scoreDetails"} 46 } 47 }, 48 { 49 "$limit": 20 50 } 51 ]);
[ { _id: ObjectId('573a1397f29313caabce68f6'), plot: "Luke Skywalker joins forces with a Jedi Knight, a cocky pilot, a wookiee and two droids to save the universe from the Empire's world-destroying battle-station, while also attempting to rescue Princess Leia from the evil Darth Vader.", title: 'Star Wars: Episode IV - A New Hope', scoreDetails: { value: 0.01626123744050767, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 2, weight: 0.5, value: 2.9629626274108887, details: [] }, { inputPipelineName: 'vectorPipeline', rank: 1, weight: 0.5, value: 0.9400461912155151, details: [] } ] } }, { _id: ObjectId('573a139af29313caabcf0f5f'), plot: 'Two Jedi Knights escape a hostile blockade to find allies and come across a young boy who may bring balance to the Force, but the long dormant Sith resurface to reclaim their old glory.', title: 'Star Wars: Episode I - The Phantom Menace', scoreDetails: { value: 0.016129032258064516, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 2, weight: 0.5, value: 2.9629626274108887, details: [] }, { inputPipelineName: 'vectorPipeline', rank: 2, weight: 0.5, value: 0.9308199286460876, details: [] } ] } }, { _id: ObjectId('573a13c0f29313caabd62f62'), plot: 'Anakin Skywalker and Ahsoka Tano must rescue the kidnapped son of Jabba the Hutt, but political intrigue complicates their mission.', title: 'Star Wars: The Clone Wars', scoreDetails: { value: 0.015889029003783105, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 1, weight: 0.5, value: 3.6164965629577637, details: [] }, { inputPipelineName: 'vectorPipeline', rank: 5, weight: 0.5, value: 0.9257078170776367, details: [] } ] } }, { _id: ObjectId('573a1397f29313caabce77d9'), plot: 'After the rebels have been brutally overpowered by the Empire on their newly established base, Luke Skywalker takes advanced Jedi training with Master Yoda, while his friends are pursued by Darth Vader as part of his plan to capture Luke.', title: 'Star Wars: Episode V - The Empire Strikes Back', scoreDetails: { value: 0.015749007936507936, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 4, weight: 0.5, value: 2.7174296379089355, details: [] }, { inputPipelineName: 'vectorPipeline', rank: 3, weight: 0.5, value: 0.9270252585411072, details: [] } ] } }, { _id: ObjectId('573a1397f29313caabce8cdb'), plot: 'After rescuing Han Solo from the palace of Jabba the Hutt, the rebels attempt to destroy the second Death Star, while Luke struggles to make Vader return from the dark side of the Force.', title: 'Star Wars: Episode VI - Return of the Jedi', scoreDetails: { value: 0.015625, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 4, weight: 0.5, value: 2.7174296379089355, details: [] }, { inputPipelineName: 'vectorPipeline', rank: 4, weight: 0.5, value: 0.9263832569122314, details: [] } ] } }, { _id: ObjectId('573a139af29313caabcf1258'), plot: 'Ten years after initially meeting, Anakin Skywalker shares a forbidden romance with Padmè, while Obi-Wan investigates an assassination attempt on the Senator and discovers a secret clone army crafted for the Jedi.', title: 'Star Wars: Episode II - Attack of the Clones', scoreDetails: { value: 0.015165441176470588, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 4, weight: 0.5, value: 2.7174296379089355, details: [] }, { inputPipelineName: 'vectorPipeline', rank: 8, weight: 0.5, value: 0.9229284524917603, details: [] } ] } }, { _id: ObjectId('573a139af29313caabcf124d'), plot: 'As the Clone Wars near an end, the Sith Lord Darth Sidious steps out of the shadows, at which time Anakin succumbs to his emotions, becoming Darth Vader and putting his relationships with Obi-Wan and Padme at risk.', title: 'Star Wars: Episode III - Revenge of the Sith', scoreDetails: { value: 0.014569256756756757, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 4, weight: 0.5, value: 2.7174296379089355, details: [] }, { inputPipelineName: 'vectorPipeline', rank: 14, weight: 0.5, value: 0.9172446727752686, details: [] } ] } }, { _id: ObjectId('573a1397f29313caabce6f53'), plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...', title: 'Message from Space', scoreDetails: { value: 0.007575757575757576, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 6, weight: 0.5, value: 0.9238690137863159, details: [] } ] } }, { _id: ObjectId('573a139df29313caabcfa90b'), plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...', title: 'Message from Space', scoreDetails: { value: 0.007575757575757576, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 6, weight: 0.5, value: 0.9238690137863159, details: [] } ] } }, { _id: ObjectId('573a13d9f29313caabda92ff'), plot: 'A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe.', title: 'Guardians of the Galaxy', scoreDetails: { value: 0.007246376811594203, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 9, weight: 0.5, value: 0.9183617234230042, details: [] } ] } }, { _id: ObjectId('573a13d5f29313caabd9c312'), plot: 'A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe.', title: 'Guardians of the Galaxy', scoreDetails: { value: 0.007142857142857143, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 10, weight: 0.5, value: 0.9183551073074341, details: [] } ] } }, { _id: ObjectId('573a13d4f29313caabd9887f'), plot: 'In this breathtaking science fiction spectacle, a strange mechanical device lands on a desolate world and uses the planet to undergo a startling transformation, that has profound implications for an entire galaxy.', title: 'Abiogenesis', scoreDetails: { value: 0.007042253521126761, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 11, weight: 0.5, value: 0.918245792388916, details: [] } ] } }, { _id: ObjectId('573a1398f29313caabce9091'), plot: "A Duke's son leads desert warriors against the galactic emperor and his father's evil nemesis when they assassinate his father and free their desert world from the emperor's rule.", title: 'Dune', scoreDetails: { value: 0.006944444444444444, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 12, weight: 0.5, value: 0.9180452823638916, details: [] } ] } }, { _id: ObjectId('573a1398f29313caabce90bd'), plot: 'Wicket the Ewok and his friends agree to help two shipwrecked human children on a quest to find their parents.', title: 'The Ewok Adventure', scoreDetails: { value: 0.00684931506849315, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 13, weight: 0.5, value: 0.9176332354545593, details: [] } ] } }, { _id: ObjectId('573a1398f29313caabce8d67'), plot: 'A futuristic, sensitive tale of adventure and confrontation when a 10 year old boy is accidentally kidnapped by a spaceship filled with a motley crew of space pirates.', title: 'Space Raiders', scoreDetails: { value: 0.006666666666666667, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 15, weight: 0.5, value: 0.916418731212616, details: [] } ] } }, { _id: ObjectId('573a13b0f29313caabd33d15'), plot: 'Two young brothers are drawn into an intergalactic adventure when their house is hurled through the depths of space by the magical board game they are playing.', title: 'Zathura: A Space Adventure', scoreDetails: { value: 0.006578947368421052, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 16, weight: 0.5, value: 0.9160659909248352, details: [] } ] } }, { _id: ObjectId('573a1397f29313caabce7509'), plot: 'An outlaw smuggler and her alien companion are recruited by the Emperor of the Galaxy to rescue his son and destroy a secret weapon by the evil Count Zarth Arn.', title: 'Starcrash', scoreDetails: { value: 0.006493506493506494, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 17, weight: 0.5, value: 0.915353000164032, details: [] } ] } }, { _id: ObjectId('573a139bf29313caabcf3d4b'), plot: 'An Air Force astronaut crash lands on a mysterious planet where evolved, talking apes dominate a race of primitive humans.', title: 'Planet of the Apes', scoreDetails: { value: 0.00641025641025641, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 18, weight: 0.5, value: 0.9140176773071289, details: [] } ] } }, { _id: ObjectId('573a13a3f29313caabd0ec59'), plot: 'An Air Force astronaut crash lands on a mysterious planet where evolved, talking apes dominate a race of primitive humans.', title: 'Planet of the Apes', scoreDetails: { value: 0.00641025641025641, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 18, weight: 0.5, value: 0.9140176773071289, details: [] } ] } }, { _id: ObjectId('573a13b0f29313caabd34a3e'), plot: 'A spaceship arrives in Arizona, 1873, to take over the Earth, starting with the Wild West region. A posse of cowboys and natives are all that stand in their way.', title: 'Cowboys & Aliens', scoreDetails: { value: 0.00625, description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:', details: [ { inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 }, { inputPipelineName: 'vectorPipeline', rank: 20, weight: 0.5, value: 0.9139271974563599, details: [] } ] } } ]
About the Query
The sample query retrieves the sorted search results from the semantic search and the full-text search, and assigns a reciprocal rank score to the documents in the results based on their position in the results array. The reciprocal rank score is calculated by using the following formula:
1.0/{document position in the results + constant value}
The query then adds the scores from both the searches for each document,
ranks the documents based on the combined score, and sorts the documents
to return a single result. The value for constant is always 60
.
The sample query defines the following weights to the pipelines to influence that pipeline's rank contribution to the final score:
vectorPipeline
= 0.5fullTextPipeline
= 0.5
You can adjust the weights to give more importance to one method of search. Note that a lower number provides higher weight.
The weighted reciprocal rank score is calculated by using the following formula:
weight x reciprocal rank
The scoreDetails.value
shows the raw score from that pipeline
before it is weighted and combined by using reciprocal rank fusion. The
scoreDetails.details.value
shows the weighted reciprocal rank score.
The sample query uses the $rankFusion
stage to execute the
semantic and full text queries independently and then de-duplicate and
combine the input query results into a final ranked results set. It
returns a ranked set of documents based on the ranks that appear in
their input pipelines and the pipeline weights. Specifically, this stage
takes the following input pipelines:
| This pipeline contains the |
|
The sample query uses the following stages to combine the results of the semantic and text search and return a single ranked list of documents in the results:
Learn by Watching
Watch a demonstration of an application that showcases hybrid search queries combining Atlas Search full-text and vector search to return a single merged result set. The application implements Relative Score Fusion (RSF) and Reciprocal Rank Fusion (RRF) to return a merged set created by using a rank fusion algorithm.
Duration: 2.43 Minutes