Run Vector Search Queries
On this page
Atlas Vector Search queries take the form of an
aggregation pipeline stage. For the
$vectorSearch
queries, Atlas Vector Search returns the results of your
semantic search.
Note
Atlas Vector Search supports ANN search on clusters running MongoDB v6.0.11, v7.0.2, or later and ENN search on clusters running MongoDB v6.0.16, v7.0.10, v7.3.2, or later.
Definition
The $vectorSearch
stage performs an ANN or ENN search on
a vector in the specified field.
ANN Search
For ANN search, Atlas Vector Search finds vector embeddings in your data that are closest to the vector embedding in your query based on their proximity in multi-dimensional space and based on the number of neighbors that it considers. It uses the Hierarchical Navigable Small Worlds algorithm and finds the vector embeddings most similar to the vector embedding in your query without scanning every vector. Therefore, ANN search is ideal for querying large datasets without significant filtering.
ENN Search
For ENN search, Atlas Vector Search exhaustively searches all the indexed vector embeddings by calculating the distance between all the embeddings and finds the exact nearest neighbor for the vector embedding in your query. This is computationally intensive and might negatively impact query latency. Therefore, we recommend ENN searches for the following use-cases:
You want to determine the recall and accuracy of your ANN query using the ideal, exact results for the ENN query.
You want to query less than 10000 documents without having to tune the number of nearest neighbors to consider.
Your want to include selective pre-filters in your query against collections where less than 5% of your data meets the given pre-filter.
Syntax
The field that you want to search must be indexed as Atlas Vector Search vector type inside a vectorSearch index type.
$vectorSearch
A
$vectorSearch
pipeline has the following prototype form:{ "$vectorSearch": { "exact": true | false, "filter": {<filter-specification>}, "index": "<index-name>", "limit": <number-of-results>, "numCandidates": <number-of-candidates>, "path": "<field-to-search>", "queryVector": [<array-of-numbers>] } }
Fields
The $vectorSearch
stage takes a document with the following fields:
Field | Type | Necessity | Description |
---|---|---|---|
exact | boolean | Optional | This is required if Flag that specifies whether to run ENN or ANN search. Value can be one of the following:
If omitted, defaults to ENN search is supported on Atlas clusters running MongoDB version 6.0.16, 7.0.10, 7.32, or later. |
filter | document | Optional | Any MQL match expression that
compares an indexed field with a boolean, date, objectId, number
(not decimals), or string to use as a pre-filter.
To learn which query and aggregation
pipeline operators Atlas Vector Search supports
in your filter, see Atlas Vector Search Pre-Filter. |
index | string | Required | Name of the Atlas Vector Search index to use. Atlas Vector Search doesn't return results if you misspell the index name or if the specified index doesn't already exist on the cluster. |
limit | number | Required | Number (of type int only) of documents to return in the
results. This alue can't exceed the value of numCandidates if
you specify numCandidates . |
numCandidates | number | Optional | This field is required if Number of nearest neighbors to use during the search. Value must
be less than or equal to ( We recommend that you specify a number higher than the number of
documents to return ( |
path | string | Required | Indexed vectorEmbedding
type field to search. To learn more, see Path Construction. |
queryVector | array of numbers | Required | Array of numbers of the BSON NoteYou must embed your query with the same model that you used to embed the data. |
Behavior
$vectorSearch
must be the first stage of any pipeline where it
appears.
Atlas Vector Search Index
You must index the fields to search using the $vectorSearch
stage inside a vectorSearch type index
definition. You can index the following types of fields in an Atlas Vector Search
vectorSearch type index definition:
Fields that contain vector embeddings as vector type.
Fields that contain boolean, date, objectId, numeric, and string values as filter type to enable vector search on pre-filtered data.
To learn more about these Atlas Vector Search field types, see How to Index Fields for Vector Search.
Atlas Vector Search Score
Atlas Vector Search assigns a score, in a fixed range from 0
to 1
only, to
every document that it returns. For cosine
and dotProduct
similarities, Atlas Vector Search normalizes
the score using the following algorithm:
score = (1 + cosine/dot_product(v1,v2)) / 2
The score assigned to a returned document is part of the document's
metadata. To include each returned document's score along with the
result set, use a $project
stage in your aggregation
pipeline.
To retrieve the score of your Atlas Vector Search query results, use
vectorSearchScore
as the value in the $meta expression. That is, after the
$vectorSearch
stage, in the $project
stage, the
score
field takes the $meta expression. The expression
requires the vectorSearchScore
value to return the score of
documents for the vector search.
Example
1 db.<collection>.aggregate([ 2 { 3 "$vectorSearch": { 4 <query-syntax> 5 } 6 }, 7 { 8 "$project": { 9 "<field-to-include>": 1, 10 "<field-to-exclude>": 0, 11 "score": { "$meta": "vectorSearchScore" } 12 } 13 } 14 ])
Note
Pre-filtering your data doesn't affect the score that Atlas Vector Search returns
using $vectorSearchScore
for $vectorSearch
queries.
Atlas Vector Search Pre-Filter
The $vectorSearch
filter
option matches only BSON
boolean, date, objectId, string, and numeric values. You must index the fields
that you want to filter your data by as the filter type in a vectorSearch type index definition. Filtering your data is
useful to narrow the scope of your semantic search and ensure that not
all vectors are considered for comparison.
Atlas Vector Search supports the $vectorSearch
filter
option
for the following MQL
match expressions, with the exception of certain
limitations:
The $vectorSearch
filter
option supports only the following
aggregation pipeline
operators:
Note
The $vectorSearch
filter
option doesn't support other
query
and aggregation pipeline
operators.
Limitations
$vectorSearch
is supported only on Atlas clusters
running the following MongoDB versions:
v6.0.11
v7.0.2 and later (including RCs).
The $vectorSearch
filter
option on
fields with the objectId type
does not support the following MQL
match expressions:
$vectorSearch
can't be used in
view definition and the following pipeline
stages:
$lookup
sub-pipeline$unionWith
sub-pipeline$facet
pipeline stage
You can pass the results of $vectorSearch
to this stage.
Supported Clients
You can run $vectorSearch
queries using the Atlas
Data Explorer, mongosh
, and the following drivers:
You can also use Atlas Vector Search with local Atlas deployments that you create with the Atlas CLI. To learn more, see Create a Local Atlas Deployment.
Parallel Query Execution Across Segments
We recommend dedicated Search Nodes to isolate vector search query processing. You might see improved query performance on the dedicated Search Nodes. Note that the high-CPU systems might provide more performance improvement. When Atlas Vector Search runs on search nodes, Atlas Vector Search parallelizes query execution across segments of data.
Parallelization of query processing improves the response time in many cases, such as queries on large datasets. Using intra-query parallelism during Atlas Vector Search query processing utilizes more resources, but improves latency for each individual query.
Note
Atlas Vector Search doesn't guarantee that each query will run concurrently. For example, when too many concurrent queries are queued, Atlas Vector Search might fall back to single-threaded execution.
Examples
The following queries search the sample sample_mflix.embedded_movies
collection using the $vectorSearch
stage. The queries search
the plot_embedding
field, which contains embeddings created using
OpenAI's text-embedding-ada-002
embeddings model. If you added the
sample collection to your Atlas
cluster and created the sample indexes
for the collection, you can run the following queries against the
collection.
Note
Pasting the queryVector
from the sample code into your terminal
might take a while depending on your machine.
➤ Use the Select your language drop-down menu to set the language of the examples in this page.
ANN Examples
The following query uses the $vectorSearch
stage to search
the plot_embedding
field using vector embeddings for the string
time travel. It considers up to 150
nearest neighbors, and
returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include only theplot
andtitle
fields in the results.Add a field named
score
that shows the vector search score for each document in the results.
1 db.embedded_movies.aggregate([ 2 { 3 "$vectorSearch": { 4 "index": "vector_index", 5 "path": "plot_embedding", 6 "queryVector": [-0.0016261312,-0.028070757,-0.011342932,-0.012775794,-0.0027440966,0.008683807,-0.02575152,-0.02020668,-0.010283281,-0.0041719596,0.021392956,0.028657231,-0.006634482,0.007490867,0.018593878,0.0038187427,0.029590257,-0.01451522,0.016061379,0.00008528442,-0.008943722,0.01627464,0.024311995,-0.025911469,0.00022596726,-0.008863748,0.008823762,-0.034921836,0.007910728,-0.01515501,0.035801545,-0.0035688248,-0.020299982,-0.03145631,-0.032256044,-0.028763862,-0.0071576433,-0.012769129,0.012322609,-0.006621153,0.010583182,0.024085402,-0.001623632,0.007864078,-0.021406285,0.002554159,0.012229307,-0.011762793,0.0051682983,0.0048484034,0.018087378,0.024325324,-0.037694257,-0.026537929,-0.008803768,-0.017767483,-0.012642504,-0.0062712682,0.0009771782,-0.010409906,0.017754154,-0.004671795,-0.030469967,0.008477209,-0.005218282,-0.0058480743,-0.020153364,-0.0032805866,0.004248601,0.0051449724,0.006791097,0.007650814,0.003458861,-0.0031223053,-0.01932697,-0.033615597,0.00745088,0.006321252,-0.0038154104,0.014555207,0.027697546,-0.02828402,0.0066711367,0.0077107945,0.01794076,0.011349596,-0.0052715978,0.014755142,-0.019753495,-0.011156326,0.011202978,0.022126047,0.00846388,0.030549942,-0.0041386373,0.018847128,-0.00033655585,0.024925126,-0.003555496,-0.019300312,0.010749794,0.0075308536,-0.018287312,-0.016567878,-0.012869096,-0.015528221,0.0078107617,-0.011156326,0.013522214,-0.020646535,-0.01211601,0.055928253,0.011596181,-0.017247654,0.0005939711,-0.026977783,-0.003942035,-0.009583511,-0.0055248477,-0.028737204,0.023179034,0.003995351,0.0219661,-0.008470545,0.023392297,0.010469886,-0.015874773,0.007890735,-0.009690142,-0.00024970944,0.012775794,0.0114762215,0.013422247,0.010429899,-0.03686786,-0.006717788,-0.027484283,0.011556195,-0.036068123,-0.013915418,-0.0016327957,0.0151016945,-0.020473259,0.004671795,-0.012555866,0.0209531,0.01982014,0.024485271,0.0105431955,-0.005178295,0.033162415,-0.013795458,0.007150979,0.010243294,0.005644808,0.017260984,-0.0045618312,0.0024725192,0.004305249,-0.008197301,0.0014203656,0.0018460588,0.005015015,-0.011142998,0.01439526,0.022965772,0.02552493,0.007757446,-0.0019726837,0.009503538,-0.032042783,0.008403899,-0.04609149,0.013808787,0.011749465,0.036388017,0.016314628,0.021939443,-0.0250051,-0.017354285,-0.012962398,0.00006107364,0.019113706,0.03081652,-0.018114036,-0.0084572155,0.009643491,-0.0034721901,0.0072642746,-0.0090636825,0.01642126,0.013428912,0.027724205,0.0071243206,-0.6858542,-0.031029783,-0.014595194,-0.011449563,0.017514233,0.01743426,0.009950057,0.0029706885,-0.015714826,-0.001806072,0.011856096,0.026444625,-0.0010663156,-0.006474535,0.0016161345,-0.020313311,0.0148351155,-0.0018393943,0.0057347785,0.018300641,-0.018647194,0.03345565,-0.008070676,0.0071443142,0.014301958,0.0044818576,0.003838736,-0.007350913,-0.024525259,-0.001142124,-0.018620536,0.017247654,0.007037683,0.010236629,0.06046009,0.0138887605,-0.012122675,0.037694257,0.0055081863,0.042492677,0.00021784494,-0.011656162,0.010276617,0.022325981,0.005984696,-0.009496873,0.013382261,-0.0010563189,0.0026507939,-0.041639622,0.008637156,0.026471283,-0.008403899,0.024858482,-0.00066686375,-0.0016252982,0.027590916,0.0051449724,0.0058647357,-0.008743787,-0.014968405,0.027724205,-0.011596181,0.0047650975,-0.015381602,0.0043718936,0.002159289,0.035908177,-0.008243952,-0.030443309,0.027564257,0.042625964,-0.0033688906,0.01843393,0.019087048,0.024578573,0.03268257,-0.015608194,-0.014128681,-0.0033538956,-0.0028757197,-0.004121976,-0.032389335,0.0034322033,0.058807302,0.010943064,-0.030523283,0.008903735,0.017500903,0.00871713,-0.0029406983,0.013995391,-0.03132302,-0.019660193,-0.00770413,-0.0038853872,0.0015894766,-0.0015294964,-0.006251275,-0.021099718,-0.010256623,-0.008863748,0.028550599,0.02020668,-0.0012962399,-0.003415542,-0.0022509254,0.0119360695,0.027590916,-0.046971202,-0.0015194997,-0.022405956,0.0016677842,-0.00018535563,-0.015421589,-0.031802863,0.03814744,0.0065411795,0.016567878,-0.015621523,0.022899127,-0.011076353,0.02841731,-0.002679118,-0.002342562,0.015341615,0.01804739,-0.020566562,-0.012989056,-0.002990682,0.01643459,0.00042527664,0.008243952,-0.013715484,-0.004835075,-0.009803439,0.03129636,-0.021432944,0.0012087687,-0.015741484,-0.0052016205,0.00080890034,-0.01755422,0.004811749,-0.017967418,-0.026684547,-0.014128681,0.0041386373,-0.013742141,-0.010056688,-0.013268964,-0.0110630235,-0.028337335,0.015981404,-0.00997005,-0.02424535,-0.013968734,-0.028310679,-0.027750863,-0.020699851,0.02235264,0.001057985,0.00081639783,-0.0099367285,0.013522214,-0.012016043,-0.00086471526,0.013568865,0.0019376953,-0.019020405,0.017460918,-0.023045745,0.008503866,0.0064678704,-0.011509543,0.018727167,-0.003372223,-0.0028690554,-0.0027024434,-0.011902748,-0.012182655,-0.015714826,-0.0098634185,0.00593138,0.018753825,0.0010146659,0.013029044,0.0003521757,-0.017620865,0.04102649,0.00552818,0.024485271,-0.009630162,-0.015608194,0.0006718621,-0.0008418062,0.012395918,0.0057980907,0.016221326,0.010616505,0.004838407,-0.012402583,0.019900113,-0.0034521967,0.000247002,-0.03153628,0.0011038032,-0.020819811,0.016234655,-0.00330058,-0.0032289368,0.00078973995,-0.021952773,-0.022459272,0.03118973,0.03673457,-0.021472929,0.0072109587,-0.015075036,0.004855068,-0.0008151483,0.0069643734,0.010023367,-0.010276617,-0.023019087,0.0068244194,-0.0012520878,-0.0015086699,0.022046074,-0.034148756,-0.0022192693,0.002427534,-0.0027124402,0.0060346797,0.015461575,0.0137554705,0.009230294,-0.009583511,0.032629255,0.015994733,-0.019167023,-0.009203636,0.03393549,-0.017274313,-0.012042701,-0.0009930064,0.026777849,-0.013582194,-0.0027590916,-0.017594207,-0.026804507,-0.0014236979,-0.022032745,0.0091236625,-0.0042419364,-0.00858384,-0.0033905501,-0.020739838,0.016821127,0.022539245,0.015381602,0.015141681,0.028817179,-0.019726837,-0.0051283115,-0.011489551,-0.013208984,-0.0047017853,-0.0072309524,0.01767418,0.0025658219,-0.010323267,0.012609182,-0.028097415,0.026871152,-0.010276617,0.021912785,0.0022542577,0.005124979,-0.0019710176,0.004518512,-0.040360045,0.010969722,-0.0031539614,-0.020366628,-0.025778178,-0.0110030435,-0.016221326,0.0036587953,0.016207997,0.003007343,-0.0032555948,0.0044052163,-0.022046074,-0.0008822095,-0.009363583,0.028230704,-0.024538586,0.0029840174,0.0016044717,-0.014181997,0.031349678,-0.014381931,-0.027750863,0.02613806,0.0004136138,-0.005748107,-0.01868718,-0.0010138329,0.0054348772,0.010703143,-0.003682121,0.0030856507,-0.004275259,-0.010403241,0.021113047,-0.022685863,-0.023032416,0.031429652,0.001792743,-0.005644808,-0.011842767,-0.04078657,-0.0026874484,0.06915057,-0.00056939584,-0.013995391,0.010703143,-0.013728813,-0.022939114,-0.015261642,-0.022485929,0.016807798,0.007964044,0.0144219175,0.016821127,0.0076241563,0.005461535,-0.013248971,0.015301628,0.0085171955,-0.004318578,0.011136333,-0.0059047225,-0.010249958,-0.018207338,0.024645219,0.021752838,0.0007614159,-0.013648839,0.01111634,-0.010503208,-0.0038487327,-0.008203966,-0.00397869,0.0029740208,0.008530525,0.005261601,0.01642126,-0.0038753906,-0.013222313,0.026537929,0.024671877,-0.043505676,0.014195326,0.024778508,0.0056914594,-0.025951454,0.017620865,-0.0021359634,0.008643821,0.021299653,0.0041686273,-0.009017031,0.04044002,0.024378639,-0.027777521,-0.014208655,0.0028623908,0.042119466,0.005801423,-0.028124074,-0.03129636,0.022139376,-0.022179363,-0.04067994,0.013688826,0.013328944,0.0046184794,-0.02828402,-0.0063412455,-0.0046184794,-0.011756129,-0.010383247,-0.0018543894,-0.0018593877,-0.00052024535,0.004815081,0.014781799,0.018007403,0.01306903,-0.020433271,0.009043689,0.033189073,-0.006844413,-0.019766824,-0.018767154,0.00533491,-0.0024575242,0.018727167,0.0058080875,-0.013835444,0.0040719924,0.004881726,0.012029372,0.005664801,0.03193615,0.0058047553,0.002695779,0.009290274,0.02361889,0.017834127,0.0049017193,-0.0036388019,0.010776452,-0.019793482,0.0067777685,-0.014208655,-0.024911797,0.002385881,0.0034988478,0.020899786,-0.0025858153,-0.011849431,0.033189073,-0.021312982,0.024965113,-0.014635181,0.014048708,-0.0035921505,-0.003347231,0.030869836,-0.0017161017,-0.0061346465,0.009203636,-0.025165047,0.0068510775,0.021499587,0.013782129,-0.0024475274,-0.0051149824,-0.024445284,0.006167969,0.0068844,-0.00076183246,0.030150073,-0.0055948244,-0.011162991,-0.02057989,-0.009703471,-0.020646535,0.008004031,0.0066378145,-0.019900113,-0.012169327,-0.01439526,0.0044252095,-0.004018677,0.014621852,-0.025085073,-0.013715484,-0.017980747,0.0071043274,0.011456228,-0.01010334,-0.0035321703,-0.03801415,-0.012036037,-0.0028990454,-0.05419549,-0.024058744,-0.024272008,0.015221654,0.027964126,0.03182952,-0.015354944,0.004855068,0.011522872,0.004771762,0.0027874154,0.023405626,0.0004242353,-0.03132302,0.007057676,0.008763781,-0.0027057757,0.023005757,-0.0071176565,-0.005238275,0.029110415,-0.010989714,0.013728813,-0.009630162,-0.029137073,-0.0049317093,-0.0008630492,-0.015248313,0.0043219104,-0.0055681667,-0.013175662,0.029723546,0.025098402,0.012849103,-0.0009996708,0.03118973,-0.0021709518,0.0260181,-0.020526575,0.028097415,-0.016141351,0.010509873,-0.022965772,0.002865723,0.0020493253,0.0020509914,-0.0041419696,-0.00039695262,0.017287642,0.0038987163,0.014795128,-0.014661839,-0.008950386,0.004431874,-0.009383577,0.0012604183,-0.023019087,0.0029273694,-0.033135757,0.009176978,-0.011023037,-0.002102641,0.02663123,-0.03849399,-0.0044152127,0.0004527676,-0.0026924468,0.02828402,0.017727496,0.035135098,0.02728435,-0.005348239,-0.001467017,-0.019766824,0.014715155,0.011982721,0.0045651635,0.023458943,-0.0010046692,-0.0031373003,-0.0006972704,0.0019043729,-0.018967088,-0.024311995,0.0011546199,0.007977373,-0.004755101,-0.010016702,-0.02780418,-0.004688456,0.013022379,-0.005484861,0.0017227661,-0.015394931,-0.028763862,-0.026684547,0.0030589928,-0.018513903,0.028363993,0.0044818576,-0.009270281,0.038920518,-0.016008062,0.0093902415,0.004815081,-0.021059733,0.01451522,-0.0051583014,0.023765508,-0.017874114,-0.016821127,-0.012522544,-0.0028390652,0.0040886537,0.020259995,-0.031216389,-0.014115352,-0.009176978,0.010303274,0.020313311,0.0064112223,-0.02235264,-0.022872468,0.0052449396,0.0005723116,0.0037321046,0.016807798,-0.018527232,-0.009303603,0.0024858483,-0.0012662497,-0.007110992,0.011976057,-0.007790768,-0.042999174,-0.006727785,-0.011829439,0.007024354,0.005278262,-0.017740825,-0.0041519664,0.0085905045,0.027750863,-0.038387362,0.024391968,0.00087721116,0.010509873,-0.00038508154,-0.006857742,0.0183273,-0.0037054466,0.015461575,0.0017394272,-0.0017944091,0.014181997,-0.0052682655,0.009023695,0.00719763,-0.013522214,0.0034422,0.014941746,-0.0016711164,-0.025298337,-0.017634194,0.0058714002,-0.005321581,0.017834127,0.0110630235,-0.03369557,0.029190388,-0.008943722,0.009363583,-0.0034222065,-0.026111402,-0.007037683,-0.006561173,0.02473852,-0.007084334,-0.010110005,-0.008577175,0.0030439978,-0.022712521,0.0054582027,-0.0012620845,-0.0011954397,-0.015741484,0.0129557345,-0.00042111133,0.00846388,0.008930393,0.016487904,0.010469886,-0.007917393,-0.011762793,-0.0214596,0.000917198,0.021672864,0.010269952,-0.007737452,-0.010243294,-0.0067244526,-0.015488233,-0.021552904,0.017127695,0.011109675,0.038067464,0.00871713,-0.0025591573,0.021312982,-0.006237946,0.034628596,-0.0045251767,0.008357248,0.020686522,0.0010696478,0.0076708077,0.03772091,-0.018700508,-0.0020676525,-0.008923728,-0.023298996,0.018233996,-0.010256623,0.0017860786,0.009796774,-0.00897038,-0.01269582,-0.018527232,0.009190307,-0.02372552,-0.042119466,0.008097334,-0.0066778013,-0.021046404,0.0019593548,0.011083017,-0.0016028056,0.012662497,-0.000059095124,0.0071043274,-0.014675168,0.024831824,-0.053582355,0.038387362,0.0005698124,0.015954746,0.021552904,0.031589597,-0.009230294,-0.0006147976,0.002625802,-0.011749465,-0.034362018,-0.0067844326,-0.018793812,0.011442899,-0.008743787,0.017474247,-0.021619547,0.01831397,-0.009037024,-0.0057247817,-0.02728435,0.010363255,0.034415334,-0.024032086,-0.0020126705,-0.0045518344,-0.019353628,-0.018340627,-0.03129636,-0.0034038792,-0.006321252,-0.0016161345,0.033642255,-0.000056075285,-0.005005019,0.004571828,-0.0024075406,-0.00010215386,0.0098634185,0.1980148,-0.003825407,-0.025191706,0.035161756,0.005358236,0.025111731,0.023485601,0.0023342315,-0.011882754,0.018287312,-0.0068910643,0.003912045,0.009243623,-0.001355387,-0.028603915,-0.012802451,-0.030150073,-0.014795128,-0.028630573,-0.0013487226,0.002667455,0.00985009,-0.0033972147,-0.021486258,0.009503538,-0.017847456,0.013062365,-0.014341944,0.005078328,0.025165047,-0.015594865,-0.025924796,-0.0018177348,0.010996379,-0.02993681,0.007324255,0.014475234,-0.028577257,0.005494857,0.00011725306,-0.013315615,0.015941417,0.009376912,0.0025158382,0.008743787,0.023832154,-0.008084005,-0.014195326,-0.008823762,0.0033455652,-0.032362677,-0.021552904,-0.0056081535,0.023298996,-0.025444955,0.0097301295,0.009736794,0.015274971,-0.0012937407,-0.018087378,-0.0039387033,0.008637156,-0.011189649,-0.00023846315,-0.011582852,0.0066411467,-0.018220667,0.0060846633,0.0376676,-0.002709108,0.0072776037,0.0034188742,-0.010249958,-0.0007747449,-0.00795738,-0.022192692,0.03910712,0.032122757,0.023898797,0.0076241563,-0.007397564,-0.003655463,0.011442899,-0.014115352,-0.00505167,-0.031163072,0.030336678,-0.006857742,-0.022259338,0.004048667,0.02072651,0.0030156737,-0.0042119464,0.00041861215,-0.005731446,0.011103011,0.013822115,0.021512916,0.009216965,-0.006537847,-0.027057758,-0.04054665,0.010403241,-0.0056281467,-0.005701456,-0.002709108,-0.00745088,-0.0024841821,0.009356919,-0.022659205,0.004061996,-0.013175662,0.017074378,-0.006141311,-0.014541878,0.02993681,-0.00028448965,-0.025271678,0.011689484,-0.014528549,0.004398552,-0.017274313,0.0045751603,0.012455898,0.004121976,-0.025458284,-0.006744446,0.011822774,-0.015035049,-0.03257594,0.014675168,-0.0039187097,0.019726837,-0.0047251107,0.0022825818,0.011829439,0.005391558,-0.016781142,-0.0058747325,0.010309938,-0.013049036,0.01186276,-0.0011246296,0.0062112883,0.0028190718,-0.021739509,0.009883412,-0.0073175905,-0.012715813,-0.017181009,-0.016607866,-0.042492677,-0.0014478565,-0.01794076,0.012302616,-0.015194997,-0.04433207,-0.020606548,0.009696807,0.010303274,-0.01694109,-0.004018677,0.019353628,-0.001991011,0.000058938927,0.010536531,-0.17274313,0.010143327,0.014235313,-0.024152048,0.025684876,-0.0012504216,0.036601283,-0.003698782,0.0007310093,0.004165295,-0.0029157067,0.017101036,-0.046891227,-0.017460918,0.022965772,0.020233337,-0.024072073,0.017220996,0.009370248,0.0010363255,0.0194336,-0.019606877,0.01818068,-0.020819811,0.007410893,0.0019326969,0.017887443,0.006651143,0.00067394477,-0.011889419,-0.025058415,-0.008543854,0.021579562,0.0047484366,0.014062037,0.0075508473,-0.009510202,-0.009143656,0.0046817916,0.013982063,-0.0027990784,0.011782787,0.014541878,-0.015701497,-0.029350337,0.021979429,0.01332228,-0.026244693,-0.0123492675,-0.003895384,0.0071576433,-0.035454992,-0.00046984528,0.0033522295,0.039347045,0.0005119148,0.00476843,-0.012995721,0.0024042083,-0.006931051,-0.014461905,-0.0127558,0.0034555288,-0.0074842023,-0.030256703,-0.007057676,-0.00807734,0.007804097,-0.006957709,0.017181009,-0.034575284,-0.008603834,-0.005008351,-0.015834786,0.02943031,0.016861115,-0.0050849924,0.014235313,0.0051449724,0.0025924798,-0.0025741523,0.04289254,-0.002104307,0.012969063,-0.008310596,0.00423194,0.0074975314,0.0018810473,-0.014248641,-0.024725191,0.0151016945,-0.017527562,0.0018727167,0.0002830318,0.015168339,0.0144219175,-0.004048667,-0.004358565,0.011836103,-0.010343261,-0.005911387,0.0022825818,0.0073175905,0.00403867,0.013188991,0.03334902,0.006111321,0.008597169,0.030123414,-0.015474904,0.0017877447,-0.024551915,0.013155668,0.023525586,-0.0255116,0.017220996,0.004358565,-0.00934359,0.0099967085,0.011162991,0.03092315,-0.021046404,-0.015514892,0.0011946067,-0.01816735,0.010876419,-0.10124666,-0.03550831,0.0056348112,0.013942076,0.005951374,0.020419942,-0.006857742,-0.020873128,-0.021259667,0.0137554705,0.0057880944,-0.029163731,-0.018767154,-0.021392956,0.030896494,-0.005494857,-0.0027307675,-0.006801094,-0.014821786,0.021392956,-0.0018110704,-0.0018843795,-0.012362596,-0.0072176233,-0.017194338,-0.018713837,-0.024272008,0.03801415,0.00015880188,0.0044951867,-0.028630573,-0.0014070367,-0.00916365,-0.026537929,-0.009576847,-0.013995391,-0.0077107945,0.0050016865,0.00578143,-0.04467862,0.008363913,0.010136662,-0.0006268769,-0.006591163,0.015341615,-0.027377652,-0.00093136,0.029243704,-0.020886457,-0.01041657,-0.02424535,0.005291591,-0.02980352,-0.009190307,0.019460259,-0.0041286405,0.004801752,0.0011787785,-0.001257086,-0.011216307,-0.013395589,0.00088137644,-0.0051616337,0.03876057,-0.0033455652,0.00075850025,-0.006951045,-0.0062112883,0.018140694,-0.006351242,-0.008263946,0.018154023,-0.012189319,0.0075508473,-0.044358727,-0.0040153447,0.0093302615,-0.010636497,0.032789204,-0.005264933,-0.014235313,-0.018393943,0.007297597,-0.016114693,0.015021721,0.020033404,0.0137688,0.0011046362,0.010616505,-0.0039453674,0.012109346,0.021099718,-0.0072842683,-0.019153694,-0.003768759,0.039320387,-0.006747778,-0.0016852784,0.018154023,0.0010963057,-0.015035049,-0.021033075,-0.04345236,0.017287642,0.016341286,-0.008610498,0.00236922,0.009290274,0.028950468,-0.014475234,-0.0035654926,0.015434918,-0.03372223,0.004501851,-0.012929076,-0.008483873,-0.0044685286,-0.0102233,0.01615468,0.0022792495,0.010876419,-0.0059647025,0.01895376,-0.0069976957,-0.0042952523,0.017207667,-0.00036133936,0.0085905045,0.008084005,0.03129636,-0.016994404,-0.014915089,0.020100048,-0.012009379,-0.006684466,0.01306903,0.00015765642,-0.00530492,0.0005277429,0.015421589,0.015528221,0.032202728,-0.003485519,-0.0014286962,0.033908837,0.001367883,0.010509873,0.025271678,-0.020993087,0.019846799,0.006897729,-0.010216636,-0.00725761,0.01818068,-0.028443968,-0.011242964,-0.014435247,-0.013688826,0.006101324,-0.0022509254,0.013848773,-0.0019077052,0.017181009,0.03422873,0.005324913,-0.0035188415,0.014128681,-0.004898387,0.005038341,0.0012320944,-0.005561502,-0.017847456,0.0008538855,-0.0047884234,0.011849431,0.015421589,-0.013942076,0.0029790192,-0.013702155,0.0001199605,-0.024431955,0.019926772,0.022179363,-0.016487904,-0.03964028,0.0050849924,0.017487574,0.022792496,0.0012504216,0.004048667,-0.00997005,0.0076041627,-0.014328616,-0.020259995,0.0005598157,-0.010469886,0.0016852784,0.01716768,-0.008990373,-0.001987679,0.026417969,0.023792166,0.0046917885,-0.0071909656,-0.00032051947,-0.023259008,-0.009170313,0.02071318,-0.03156294,-0.030869836,-0.006324584,0.013795458,-0.00047151142,0.016874444,0.00947688,0.00985009,-0.029883493,0.024205362,-0.013522214,-0.015075036,-0.030603256,0.029270362,0.010503208,0.021539574,0.01743426,-0.023898797,0.022019416,-0.0068777353,0.027857494,-0.021259667,0.0025758184,0.006197959,0.006447877,-0.00025200035,-0.004941706,-0.021246338,-0.005504854,-0.008390571,-0.0097301295,0.027244363,-0.04446536,0.05216949,0.010243294,-0.016008062,0.0122493,-0.0199401,0.009077012,0.019753495,0.006431216,-0.037960835,-0.027377652,0.016381273,-0.0038620618,0.022512587,-0.010996379,-0.0015211658,-0.0102233,0.007071005,0.008230623,-0.009490209,-0.010083347,0.024431955,0.002427534,0.02828402,0.0035721571,-0.022192692,-0.011882754,0.010056688,0.0011904413,-0.01426197,-0.017500903,-0.00010985966,0.005591492,-0.0077707744,-0.012049366,0.011869425,0.00858384,-0.024698535,-0.030283362,0.020140035,0.011949399,-0.013968734,0.042732596,-0.011649498,-0.011982721,-0.016967745,-0.0060913274,-0.007130985,-0.013109017,-0.009710136], 7 "numCandidates": 150, 8 "limit": 10 9 } 10 }, 11 { 12 "$project": { 13 "_id": 0, 14 "plot": 1, 15 "title": 1, 16 "score": { $meta: "vectorSearchScore" } 17 } 18 } 19 ])
1 [ 2 { 3 plot: 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.', 4 title: 'Thrill Seekers', 5 score: 0.7892671227455139 6 }, 7 { 8 plot: 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.', 9 title: 'About Time', 10 score: 0.7843604683876038 11 }, 12 { 13 plot: 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.', 14 title: 'The Time Machine', 15 score: 0.7801066637039185 16 }, 17 { 18 plot: "After using his mother's newly built time machine, Dolf gets stuck involuntary in the year 1212. He ends up in a children's crusade where he confronts his new friends with modern techniques...", 19 title: 'Crusade in Jeans', 20 score: 0.7789170742034912 21 }, 22 { 23 plot: 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.', 24 title: 'Timecop', 25 score: 0.7771612405776978 26 }, 27 { 28 plot: 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...', 29 title: 'A.P.E.X.', 30 score: 0.7730885744094849 31 }, 32 { 33 plot: "Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.", 34 title: 'Men in Black 3', 35 score: 0.7712380886077881 36 }, 37 { 38 plot: 'Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.', 39 title: 'Tomorrowland', 40 score: 0.7669923901557922 41 }, 42 { 43 plot: 'With the help of his uncle, a man travels to the future to try and bring his girlfriend back to life.', 44 title: 'Love Story 2050', 45 score: 0.7649372816085815 46 }, 47 { 48 plot: 'A dimension-traveling wizard gets stuck in the 21st century because cell-phone radiation interferes with his magic. With his home world on the brink of war, he seeks help from a jaded ...', 49 title: 'The Portal', 50 score: 0.7640786170959473 51 } 52 ]
The following query filters the documents for movies released between
January 01, 1955
and January 01, 1975
before performing the
semantic search against the sample vector data. It uses the
$and
operator to perform a logical AND
operation of the
specified dates. It then searches the plot_embedding
field in the
filtered documents for 150
nearest neighbors using the vector
embeddings for the string kids adventure, and returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include onlyplot
,title
, andyear
fields in the results.Add a field named
score
that shows the vector search score of the documents in the results.
1 db.embedded_movies.aggregate([ 2 { 3 "$vectorSearch": { 4 "index": "vector-search-tutorial", 5 "path": "plot_embedding", 6 "filter": { 7 "$and": [ 8 { 9 "year": { "$gt": 1955 } 10 }, 11 { 12 "year": { "$lt": 1975 } 13 } 14 ] 15 }, 16 "queryVector": [0.02421053,-0.022372592,-0.006231137,-0.02168502,-0.020375984,0.037552103,-0.010505334,-0.027026938,0.0070674648,-0.020032197,0.01783725,0.016303431,0.014584498,-0.018736385,0.009031017,-0.0045981496,0.02750295,-0.028322749,0.010624337,-0.024236975,-0.0048659067,0.015153068,-0.000490888,-0.022161031,-0.0024560927,-0.007411252,0.009745035,-0.01886861,0.02112967,-0.011939983,0.015153068,0.0025800543,0.017824028,-0.02410475,-0.016633997,-0.0018214093,-0.008323609,-0.009222744,0.009388026,-0.0028296304,0.0017536436,0.0065517845,-0.011635863,-0.028454976,-0.018934723,0.012951509,-0.0032015154,-0.005880739,-0.03115238,0.012951509,0.0057749585,0.009202911,-0.0069352393,0.00205611,0.0063732797,0.0039700773,-0.007100521,-0.0077087595,0.011596196,-0.010207825,-0.007100521,-0.0051006074,-0.01670011,0.012773004,-0.035304267,-0.0074971984,0.0025800543,-0.006118745,0.030253245,-0.0010751605,0.039456155,0.007821151,-0.0017189344,-0.0010801188,0.0062575825,-0.011490415,-0.022637043,0.004743598,-0.012601111,0.0197413,-0.0015255542,-0.025942687,-0.03284487,0.020389207,0.009797926,0.0141217075,-0.0015172901,0.025982354,-0.011589585,-0.001138794,0.0006131968,0.016832335,0.017916586,0.014412603,-0.0027155858,0.011854036,-0.02169824,0.02112967,-0.020680103,-0.007391418,-0.012872174,0.021473458,0.0047766543,-0.0048394613,-0.024395647,0.0065418677,0.009797926,-0.00449898,0.041836217,0.0023833686,-0.021737909,0.0136721395,0.014148152,-0.028772317,-0.027899627,-0.015695194,-0.012521776,0.02205525,-0.01927851,-0.022068473,0.020971,0.02317917,0.030544141,-0.011827591,0.0075170323,0.023086611,-0.02164535,-0.01732157,0.007510421,-0.027635176,0.016263764,-0.0008801275,0.033109322,-0.014505162,-0.029909458,0.036679417,0.0074971984,0.0059137954,-0.031178825,-0.012634167,0.008416167,0.030491251,-0.016832335,-0.009507029,0.010016099,0.009778093,0.007840985,0.010928456,-0.009685534,-0.027661622,0.024752656,-0.024871659,0.01516629,0.002778393,0.0059501575,0.022042029,0.0005441915,0.0076889256,-0.009883873,-0.019966085,0.008508725,0.0098045375,0.0091169635,-0.02750295,0.012501942,0.03480181,0.021751132,0.020746216,0.003546955,-0.014690278,0.010445832,0.008469057,-0.00007535833,0.0059600743,-0.013526691,0.029539226,-0.011126795,0.025400562,-0.025466675,-0.0046080663,-0.013923368,-0.009011183,0.019318178,0.019053727,-0.012085431,-0.0074707535,0.0013024234,0.0076624807,0.0060460214,-0.0023007276,0.017757915,0.031258162,0.0008768218,-0.003695709,-0.6981518,-0.012058986,0.008931847,-0.02914255,0.00833022,0.028349195,0.013857256,0.0029668147,-0.008164939,-0.001494977,-0.0011197866,0.0104855,0.014610942,-0.0066608707,0.000643774,0.0020676798,0.008607894,-0.023787407,0.020494986,0.015443964,-0.019833859,0.012905231,0.013387854,-0.020918109,0.0035800114,0.026775708,0.005920407,-0.018233927,-0.008759954,0.0005437783,-0.022081695,0.0071996907,-0.002963509,0.004092386,0.057967756,-0.015285294,-0.008978127,0.027740957,0.015853863,0.047178138,-0.018366152,-0.0064889775,0.029777233,0.0141217075,0.007847597,0.02200236,0.031125935,0.010611114,-0.00663112,-0.005940241,0.017215788,-0.019992528,-0.01644888,-0.013447356,0.001490845,0.007893875,0.016276987,-0.0062939445,0.00032333322,0.0020230536,-0.025360893,0.028587202,-0.009645866,0.01459772,-0.012376328,0.03202507,-0.006059244,0.010888788,0.014518384,-0.034405135,0.023364285,0.018895056,-0.009361581,-0.0011255714,0.00663112,0.016885225,0.01609187,-0.006750123,-0.035304267,0.0022660184,0.027714511,0.01680589,-0.03686453,-0.008045935,0.052943178,-0.0091169635,-0.0066840104,0.018405821,0.00027374856,0.0005235312,0.0138969235,0.018075256,0.0005850988,-0.0074971984,0.0011255714,-0.011054071,-0.0022048638,0.0043931995,0.021142893,-0.02472621,-0.007232747,0.0014858865,-0.00062228733,-0.017903363,-0.0013495288,-0.0001454483,0.0027370725,0.0060129645,0.0364943,-0.04601455,-0.008713675,-0.017215788,-0.017784359,-0.007100521,-0.014610942,-0.027978962,0.0046179835,-0.010267328,0.036785197,-0.019542962,0.028719427,0.004343615,0.0067765685,-0.018075256,-0.004462618,0.010121879,-0.0024957606,-0.00883929,0.0017007533,-0.011371412,-0.007788095,0.002418078,-0.01053839,-0.018458711,-0.0048328503,0.0035072872,0.0043568374,-0.006389808,0.027635176,-0.002768476,-0.033479553,-0.0069749067,-0.00096276856,-0.0034048124,0.012773004,-0.01979419,-0.003675875,-0.011655698,-0.026709596,-0.0009206216,-0.009295468,0.011391246,0.0050510224,0.0027486421,0.0024246892,-0.01264739,0.004687402,-0.0058377655,0.0117945345,-0.009388026,0.010545001,0.020481765,-0.000089768866,-0.022425482,-0.013487023,-0.008316998,-0.019503294,0.025942687,0.0076889256,-0.03355889,-0.0071071326,-0.019106617,-0.015430742,0.021724686,0.0019652047,0.011113572,-0.019410737,-0.023615515,0.000523118,0.019027282,-0.015853863,-0.011887092,-0.021804022,-0.013473801,-0.0049518533,-0.00071773777,-0.003194904,0.046411227,-0.0108689545,0.04003795,-0.0026626955,0.03146972,-0.005804709,-0.013645695,0.0046973187,-0.010148324,0.02292794,0.0310466,0.018709939,0.020005751,0.028534312,-0.02134123,0.044031166,-0.00021548661,0.018458711,-0.038795028,-0.00930208,-0.013738252,0.029486336,-0.0019503294,0.008812845,-0.02755584,0.004852684,-0.013301908,0.000006940559,0.017453795,-0.005249361,0.0069352393,-0.023205614,-0.02040243,-0.0060493266,-0.017110009,0.011417692,0.006882349,-0.019556185,0.015893532,-0.0028874793,-0.0023387424,-0.0034610082,-0.009427694,-0.009705368,0.002194947,-0.008191383,0.021804022,-0.016250541,0.0053320024,0.037393436,-0.014174597,0.031073045,0.004108914,0.010029321,0.018538047,0.007675703,-0.012568055,-0.0080525465,0.0013487024,0.03234241,-0.009983042,-0.014782836,0.0069418503,-0.014346491,-0.0009875608,-0.024924548,0.035145596,0.009592976,-0.010902011,0.0047568204,0.006194775,0.011344967,0.028349195,0.0062410543,-0.0027172386,0.011080516,0.012303604,0.012263936,-0.009844205,-0.004766737,-0.0062079974,-0.005748513,-0.01979419,-0.006036104,-0.018630605,-0.00050204457,-0.013830811,0.0015338184,-0.00418825,-0.020799106,-0.016792666,-0.0034015067,0.034352243,0.00915002,-0.019767746,0.016462103,0.014346491,-0.009672312,-0.032606862,-0.010035932,-0.0035238154,-0.018934723,0.012204434,-0.015946422,0.022597376,-0.00081194856,0.002740378,0.0088921795,0.0056361216,0.011549917,-0.0088789575,0.008720286,0.007424474,-0.0022263506,0.0020131366,-0.023165947,-0.037181873,0.014756391,0.011424302,-0.0057385964,-0.014690278,-0.018709939,-0.005536952,-0.0064228643,0.00418825,-0.023787407,0.012845729,-0.009487196,-0.011754867,-0.008746731,-0.013844033,0.026643483,0.009070684,-0.016554661,-0.024078304,-0.013553137,0.011146628,0.11075226,-0.007854208,0.0024098137,0.005685706,0.0032081266,-0.00603941,-0.022161031,0.0004933672,0.0014486981,-0.001134662,0.007345139,0.008237663,-0.0019057032,0.007120355,-0.009864039,0.03115238,-0.00041051954,-0.00344448,-0.013063901,-0.020997444,0.013222572,-0.002824672,0.018366152,0.025889797,0.007523644,-0.019648742,-0.007391418,0.02168502,-0.0019255371,-0.018524824,-0.00021156116,-0.004826239,-0.001088383,-0.0071468004,0.0000106013,-0.002963509,0.015430742,0.029036768,0.035806727,-0.016924892,0.039271038,0.02503033,0.019648742,-0.02636581,0.0035634832,-0.00044254295,-0.016435657,0.012792839,0.008270719,-0.03469603,0.052599393,0.008270719,-0.0052824174,-0.0059534633,0.023668405,0.011159851,-0.018128147,-0.0064856717,0.009606198,-0.015258849,0.00291723,-0.028851653,0.019133061,-0.012323437,-0.01516629,-0.027846737,-0.019820636,0.0024974134,-0.01377792,-0.00067063235,-0.022703156,-0.009156631,-0.012303604,-0.023311395,0.006174941,0.0073980293,0.012343272,-0.015721638,-0.00033097752,0.019146284,0.011761478,-0.019542962,-0.0057452074,-0.0076823146,-0.002343701,0.007840985,0.014941507,0.007847597,-0.004029579,0.008812845,0.029168995,0.01876283,0.01125902,-0.010611114,0.00021734604,-0.0037948783,-0.0016445575,0.028587202,0.015086955,0.0035899284,0.0009900401,-0.019622298,-0.00704102,-0.0062410543,0.0027106274,0.009652478,-0.01573486,0.0152985165,0.0046774847,-0.02595591,0.0115565285,-0.021989137,0.010961512,-0.011179685,0.011781312,-0.00055782724,-0.0033238241,-0.0012619293,0.02066688,-0.014372936,0.006399725,-0.022332925,0.011014403,0.01927851,-0.008733509,0.003798184,0.017744692,-0.036732305,0.0077087595,0.005454311,-0.0038676024,0.01696456,-0.00037973575,0.0058212373,-0.030517697,-0.012006096,0.012482109,0.015946422,0.0031899456,0.001283416,-0.0055898423,0.01737446,0.03633563,0.015642302,-0.002953592,-0.02446176,-0.011364801,-0.023033721,-0.003798184,0.03726121,-0.021513125,0.014505162,-0.008971515,-0.0023007276,0.0009231008,-0.03916526,-0.023364285,0.008145104,0.020997444,0.025889797,0.0302268,-0.02107678,0.03720832,-0.009936763,0.013361409,-0.00080492406,-0.015972868,-0.0035172042,-0.041968442,0.012369717,0.020389207,0.011530083,0.0016420782,-0.026947603,0.010465666,0.009983042,0.011549917,-0.013923368,-0.0075699226,-0.012442441,0.0031635005,-0.0003237464,-0.009196299,0.007920321,-0.003556872,0.0043105586,0.036520746,0.0029155773,-0.0025073302,-0.016224096,0.0094541395,-0.016409213,0.01192676,0.0008702105,0.014796059,0.002148668,-0.013414299,-0.026154248,-0.02235937,0.011801146,0.012442441,-0.0016685233,0.008898791,0.0063931136,-0.01094829,0.013963036,0.002611458,-0.015880309,0.01789014,-0.0050378,-0.0035800114,-0.016885225,0.0073120827,-0.040117282,0.005748513,0.0027536007,-0.022676712,0.008674008,-0.024699764,0.0045783157,-0.030676367,0.0008602936,0.038742136,0.010551613,0.020812329,0.0017354626,0.011278854,-0.0068559037,-0.016686887,-0.007424474,0.0022759351,0.014452271,0.0141217075,0.0020296648,-0.0016784403,-0.017810805,-0.009526864,-0.015906755,-0.012092043,0.0143597135,-0.009090519,0.01352008,-0.012620945,-0.008270719,-0.013288685,0.027978962,-0.0049882154,-0.0044791466,-0.008726898,-0.015946422,-0.02153957,0.012938287,-0.016753,0.022531264,0.015933199,-0.013361409,0.03834546,-0.001832979,-0.008773177,-0.012111876,-0.02524189,0.024792323,0.009758258,0.029327665,0.01141108,0.01022766,-0.016726553,0.008409556,0.011424302,0.023192393,0.0021354454,-0.01346719,-0.016435657,0.0051072184,-0.0037485992,-0.015338183,-0.009374804,-0.02251804,-0.026815377,-0.022703156,0.01582742,0.016951337,-0.014491939,-0.011523472,-0.018154591,0.0061418847,-0.00039378472,-0.009599588,0.00061898166,-0.026088135,-0.010809453,-0.012680447,0.0011892051,0.00817155,-0.011060682,-0.007834374,-0.0015015884,0.018974392,-0.026379032,0.01794303,-0.029063214,0.005731985,-0.015721638,0.013202738,0.018855387,-0.017043896,0.021883357,-0.00976487,-0.0063501406,0.0006817889,-0.021010667,-0.0034411745,-0.019701632,-0.015999312,-0.0065418677,0.0036130678,-0.015615858,-0.017519908,-0.035330713,0.029486336,0.0007094736,-0.015351406,-0.00010252659,-0.0019618992,0.02565179,0.0023751045,0.024382424,-0.007807929,-0.016157983,-0.008012879,-0.0076823146,0.020256981,-0.0023784102,-0.01125902,-0.017229011,-0.009163243,-0.0073980293,0.018802498,0.0007470753,0.004786571,0.038133897,0.022782492,0.0136721395,0.0048394613,-0.00033986144,0.0070608538,0.005771653,-0.026167471,-0.021394122,-0.0039237984,0.01922562,0.03868925,0.00899796,-0.021658573,-0.010809453,-0.010604503,-0.011966428,0.0051733316,0.003074248,0.017757915,0.051620923,0.0036593468,-0.016673664,0.013024233,0.004826239,0.02750295,-0.00817155,-0.012865563,0.013037456,0.01758602,-0.0006045195,0.010187992,-0.03263331,-0.015814196,0.029274775,0.0018957863,-0.009672312,0.0011966428,-0.015748084,-0.0054972842,-0.041386653,0.012250713,0.007530255,0.0047204583,0.018286817,-0.02134123,0.0033915897,-0.007391418,-0.0035304269,-0.0032180436,-0.0002681703,-0.009361581,-0.013249017,0.02036276,-0.010749951,-0.02107678,-0.017242234,-0.01644888,0.02483199,-0.0060823835,0.0042576683,0.020071864,0.014372936,-0.013963036,-0.008350055,0.005474145,-0.0029321054,-0.029512782,-0.023046944,-0.017718246,0.0016106745,-0.021618906,-0.011490415,-0.009209521,0.009282245,0.01459772,0.024567539,-0.0021073474,0.02168502,0.0021040419,-0.025770793,0.0014296906,0.0042279176,-0.009553309,-0.0041254424,-0.012396161,0.0018395904,-0.016753,-0.0076889256,-0.0010991263,-0.022782492,0.004224612,0.014518384,0.015100177,-0.01315646,0.0036362074,0.19643453,-0.006902183,-0.01223088,0.0163431,-0.0065352563,0.018723162,0.0247791,-0.0050807735,-0.0047832653,-0.009196299,-0.014928284,0.027529396,0.0019933027,0.0026180693,0.0016205915,-0.01639599,-0.02153957,-0.017202567,-0.024131194,-0.03316221,-0.00085698796,-0.0063600573,-0.03181351,-0.009037628,0.0032907678,-0.0050378,-0.0010346663,-0.01835293,0.01361925,0.026088135,0.0005751819,-0.016819112,-0.009434305,0.0023354369,-0.020997444,-0.0067402064,0.008310387,0.0040626354,0.0040890803,0.030306136,-0.015959645,0.021037113,-0.0009916929,0.0070872987,-0.01161603,0.017096786,-0.001370189,-0.0042080837,0.0008140146,0.014108485,-0.02606169,-0.010472277,0.021261897,0.019966085,-0.011735033,-0.010908622,0.0016586065,0.029697897,-0.01830004,-0.011034236,-0.0038246291,0.031787064,-0.0079401545,0.0075500887,-0.009844205,0.022161031,-0.0044097276,0.0059600743,0.011959816,-0.019371068,0.0037915725,-0.015020842,-0.010968124,-0.0062741106,-0.00012179228,-0.027053382,0.03377045,0.005725374,0.0026891406,-0.0011602807,-0.00403619,-0.0076889256,0.0040791635,-0.0040989975,-0.018895056,-0.0197413,0.014756391,0.0057914867,-0.012296992,-0.017757915,0.008422779,-0.020137977,0.003537038,-0.0011040848,0.0061286623,0.031734172,-0.011748255,0.03207796,0.008204606,-0.0043270867,-0.02652448,-0.03501337,0.0050609396,0.015615858,-0.027476504,0.0026660012,0.00057104987,0.022861827,-0.012098653,-0.0024461758,0.01022766,-0.008350055,0.0114441365,0.0022081695,-0.0044130334,0.018009143,-0.0013867173,-0.016620774,-0.0060460214,-0.01459772,0.008164939,-0.013249017,0.005748513,0.005232833,-0.024950994,-0.011490415,-0.013480413,0.021552794,0.011285465,-0.03604473,0.0041915555,-0.0052096937,0.013037456,-0.012449052,-0.013037456,0.01639599,0.0051997765,-0.002267671,0.015047288,0.018643826,0.013976259,0.0052394443,0.0059534633,0.010016099,-0.0016528215,-0.03670586,0.023483288,0.008250885,-0.0051997765,-0.012607723,-0.019133061,-0.005798098,-0.012991177,-0.001120613,0.015272071,-0.03279198,-0.040646188,-0.014994397,-0.009031017,0.014108485,-0.011424302,0.021420566,0.0053353077,0.0052361386,-0.012607723,-0.0076823146,-0.17136453,-0.0011024319,0.011351578,-0.0062278314,0.008700453,0.0017106703,0.011992873,0.0048758234,-0.004568399,-0.0052460553,0.02729139,-0.013407689,-0.041809775,0.0023552708,0.025612123,0.031337496,-0.008925236,0.017004227,0.013989481,0.005252667,0.02344362,0.023879966,-0.0006917058,0.013949813,0.0005198124,0.0051072184,0.0040791635,0.0046576513,-0.012574666,-0.013698584,-0.012654002,-0.00344448,-0.006862515,0.012944899,0.023324618,0.004743598,-0.029724343,0.006307167,0.0016453839,0.0093549695,-0.008469057,0.035648055,0.01454483,-0.0115697505,0.011344967,0.015496855,-0.013738252,-0.0026610426,-0.005923712,-0.007953377,0.01609187,-0.02698727,0.011483804,-0.014796059,0.024408868,0.009778093,-0.0014437396,0.007001352,0.022068473,-0.011701977,-0.00007365386,-0.023377508,0.012964732,-0.010445832,-0.018114924,-0.04009084,-0.0056427326,0.0071269665,-0.03300354,0.028666537,-0.025850128,-0.017440572,0.007966599,-0.026484812,0.012409384,-0.0022032112,-0.009778093,-0.005798098,-0.015430742,-0.0028775623,-0.011629253,0.035304267,-0.03295065,0.019384291,-0.009513641,0.017387683,-0.019873526,-0.011113572,-0.012052375,-0.010531778,0.010459054,-0.034458023,-0.01876283,-0.00026589766,0.008217828,0.025202222,0.0009792967,-0.005712151,0.005150192,-0.01794303,-0.0048956573,-0.010895399,-0.007345139,-0.005725374,0.036917422,-0.009447528,0.042603128,0.017969476,0.03094082,-0.0061617186,0.01459772,0.0040031336,0.004340309,0.01979419,-0.0055799256,0.020349538,-0.019040504,-0.019648742,0.019780967,-0.0012842424,0.03839835,-0.0005590669,-0.023165947,-0.011067293,0.014015927,0.012303604,-0.10461699,-0.009315303,0.00067393796,0.021195784,-0.017506685,0.009427694,0.0045055915,0.00096194213,0.015919978,0.016435657,-0.014095262,0.0028676454,-0.004730375,-0.0136721395,0.010306995,-0.0073186937,-0.013401077,-0.0090045715,-0.019344624,0.009242578,-0.016686887,0.0007702148,0.012528387,-0.012025929,-0.022689935,-0.009976431,-0.032236632,0.02750295,0.004158499,0.01855127,0.002371799,-0.0053320024,0.007715371,-0.03252753,-0.013500246,0.011973039,-0.008469057,-0.0022924636,0.0213809,-0.04842106,0.018895056,0.0015858823,0.007576534,-0.024964217,0.014994397,0.0020412346,-0.005249361,0.0014792753,0.009348359,-0.03638852,-0.028402084,-0.01084251,-0.019979307,-0.0035304269,0.0036064566,-0.014994397,0.017652133,0.01305729,0.007907098,0.006667482,0.0028676454,-0.020005751,-0.012991177,0.03001524,-0.00046609566,0.015615858,-0.02935411,-0.0009925193,0.033796895,-0.019040504,-0.014901839,0.009533474,-0.010121879,0.026458368,-0.038054563,0.009956597,-0.0030048296,-0.0019519823,0.016872002,-0.001142926,-0.014941507,-0.02930122,0.004611372,-0.029512782,0.030887928,-0.0018015754,0.010624337,-0.0044791466,-0.007993045,-0.0056790947,0.0019602464,0.011173073,0.0023222142,-0.00022499033,0.0024511344,0.015443964,0.018987615,-0.02349651,-0.008740121,0.00029730127,-0.004750209,-0.017969476,-0.06442037,0.006816236,0.0019833858,0.0063038613,-0.0054675336,-0.01161603,0.032818425,-0.030094575,0.009685534,-0.0012520123,-0.0013090346,0.0085285595,0.015959645,-0.0006574098,-0.00688896,-0.019133061,-0.0008057505,0.009672312,0.019913195,0.008145104,-0.012290381,0.0016139803,0.026405476,0.014875393,-0.002168502,0.012792839,-0.011840814,0.003464314,0.0069682957,-0.0073781954,0.018842166,-0.03165484,-0.017242234,0.006789791,-0.009130186,-0.012263936,-0.015258849,0.0036692638,0.008865735,0.0272385,-0.004009745,-0.017612467,0.022584153,-0.023760963,0.004231223,0.004287419,-0.020891665,0.022425482,0.007986434,-0.0030345803,0.010459054,0.013844033,0.012283769,-0.027899627,-0.006250971,-0.023430398,0.0122573245,-0.004128748,0.013830811,-0.016766222,0.022861827,-0.011192908,0.03665297,-0.00212057,-0.009031017,-0.024170863,-0.0010230965,-0.0064393925,0.014015927,-0.005956769,0.000146378,-0.008436001,0.010604503,0.013169682,-0.00516672,0.0012321784,-0.022332925,-0.0022643656,-0.03993217,0.02050821,0.01577453,-0.0043667546,-0.022372592,-0.001152843,0.010002876,0.0036262905,-0.017876917,0.006406336,-0.009401249,0.019569406,-0.03033258,-0.01269367,0.0020412346,0.009989654,-0.0014627471,0.04101642,0.0011189602,-0.023046944,0.0013230836,0.024250198,0.01207882,-0.0062377485,-0.010452444,-0.020825552,0.006693927,-0.005305557,-0.018339708,-0.041307315,-0.012296992,0.0070542423,0.0019371068,0.0117945345,-0.020032197,0.017797582,-0.015443964,0.00537167,-0.00015474542,-0.0117747,-0.011140017,0.017334793,0.016250541,0.006019576,0.017612467,-0.017982699,0.010366497,0.0029949127,0.015086955,-0.000027813887,-0.008660785,-0.008713675,-0.0050873845,-0.0117945345,-0.016118316,-0.0022015583,0.006518728,-0.0047766543,0.0055501745,0.039747052,-0.034061346,0.049425974,0.0023883271,-0.0035601775,0.00863434,-0.003897353,0.016237319,0.006436087,-0.00037828952,-0.017797582,-0.019450404,0.0009809496,0.0036461244,0.013176293,0.0036461244,-0.01094829,-0.018260373,0.00035246418,0.012885396,-0.006796402,-0.015972868,0.027899627,-0.0077021485,0.027608732,0.01696456,-0.0014486981,-0.017969476,0.015642302,-0.00477996,-0.0048890463,-0.020058641,0.008323609,0.013017623,-0.01886861,-0.008204606,0.016303431,-0.010029321,-0.001018138,-0.0332151,0.010525168,0.032871313,0.011549917,0.010928456,-0.014253933,-0.011384634,0.00894507,0.034616694,-0.016872002,-0.010987958,-0.011953205], 17 "numCandidates": 150, 18 "limit": 10 19 } 20 }, 21 { 22 "$project": { 23 "_id": 0, 24 "title": 1, 25 "plot": 1, 26 "year": 1, 27 "score": { $meta: "vectorSearchScore" } 28 } 29 } 30 ])
1 [ 2 { 3 plot: 'In this magical tale about the boy who refuses to grow up, Peter Pan and his mischievous fairy sidekick Tinkerbell visit the nursery of Wendy, Michael, and John Darling. With a sprinkling ...', 4 title: 'Peter Pan', 5 year: 1960, 6 score: 0.748110830783844 7 }, 8 { 9 plot: 'A down-on-his-luck inventor turns a broken-down Grand Prix car into a fancy vehicle for his children, and then they go off on a magical fantasy adventure to save their grandfather in a far-off land.', 10 title: 'Chitty Chitty Bang Bang', 11 year: 1968, 12 score: 0.7442465424537659 13 }, 14 { 15 plot: 'A young man comes to the rescue of his girlfriend abducted by thieves and brought to Rio. An extravagant adventure ensues.', 16 title: 'That Man from Rio', 17 year: 1964, 18 score: 0.7416020035743713 19 }, 20 { 21 plot: 'A pilot, stranded in the desert, meets a little boy who is a prince on a planet.', 22 title: 'The Little Prince', 23 year: 1974, 24 score: 0.7378944158554077 25 }, 26 { 27 plot: 'A red balloon with a life of its own follows a little boy around the streets of Paris.', 28 title: 'The Red Balloon', 29 year: 1956, 30 score: 0.7342712879180908 31 }, 32 { 33 plot: 'A poor boy wins the opportunity to tour the most eccentric and wonderful candy factory of all.', 34 title: 'Willy Wonka & the Chocolate Factory', 35 year: 1971, 36 score: 0.7342107892036438 37 }, 38 { 39 plot: 'An apprentice witch, three kids and a cynical conman search for the missing component to a magic spell useful to the defense of Britain.', 40 title: 'Bedknobs and Broomsticks', 41 year: 1971, 42 score: 0.7339356541633606 43 }, 44 { 45 plot: "A young boys' coming of age tale set in a strange, carnivalesque village becomes the recreation of a memory that the director has twenty years later.", 46 title: 'Pastoral Hide and Seek', 47 year: 1974, 48 score: 0.733299970626831 49 }, 50 { 51 plot: 'A young swordsman comes to Paris and faces villains, romance, adventure and intrigue with three Musketeer friends.', 52 title: 'The Three Musketeers', 53 year: 1973, 54 score: 0.7331198453903198 55 }, 56 { 57 plot: 'A fairy-tale about a conceited young man and a young woman with a tyrannical step-mother, who must overcome magical trials in order to be together.', 58 title: 'Frosty', 59 year: 1964, 60 score: 0.7318308353424072 61 } 62 ]
Atlas Vector Search filters the documents based on the year
field value that
ranges between 1955 and 1975. It returns documents that summarize
children's adventures in the plot for movies released between 1955 and
1975.
Tip
See also: Additional Filter Examples
The How to Perform Semantic Search Against Data in Your Atlas Cluster tutorial demonstrates other
pre-filters in semantic search queries against the embedded data in
the sample_mflix.embedded_movies
collection.
The following query uses the $vectorSearch
stage to search
the plot_embedding
field using vector embeddings for the string
time travel. It considers up to 150
nearest neighbors, and
returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include only theplot
andtitle
fields in the results.Add a field named
score
that shows the vector search score for each document in the results.
1 using MongoDB.Bson; 2 using MongoDB.Bson.Serialization.Attributes; 3 using MongoDB.Bson.Serialization.Conventions; 4 using MongoDB.Driver; 5 using MongoDB.Driver.Search; 6 7 public class vectorSearchBasicQuery 8 { 9 // define connection to your Atlas cluster 10 private const string MongoConnectionString = "<connection-string>"; 11 12 public static void Main(string[] args){ 13 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() }; 14 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true); 15 16 // connect to your Atlas cluster 17 var mongoClient = new MongoClient(MongoConnectionString); 18 19 // define namespace 20 var moviesDatabase = mongoClient.GetDatabase("sample_mflix"); 21 var moviesCollection = moviesDatabase.GetCollection<EmbeddedMovie>("embedded_movies"); 22 23 // define vector embeddings to search 24 var vector = new[] {-0.0016261312,-0.028070757,-0.011342932,-0.012775794,-0.0027440966,0.008683807,-0.02575152,-0.02020668,-0.010283281,-0.0041719596,0.021392956,0.028657231,-0.006634482,0.007490867,0.018593878,0.0038187427,0.029590257,-0.01451522,0.016061379,0.00008528442,-0.008943722,0.01627464,0.024311995,-0.025911469,0.00022596726,-0.008863748,0.008823762,-0.034921836,0.007910728,-0.01515501,0.035801545,-0.0035688248,-0.020299982,-0.03145631,-0.032256044,-0.028763862,-0.0071576433,-0.012769129,0.012322609,-0.006621153,0.010583182,0.024085402,-0.001623632,0.007864078,-0.021406285,0.002554159,0.012229307,-0.011762793,0.0051682983,0.0048484034,0.018087378,0.024325324,-0.037694257,-0.026537929,-0.008803768,-0.017767483,-0.012642504,-0.0062712682,0.0009771782,-0.010409906,0.017754154,-0.004671795,-0.030469967,0.008477209,-0.005218282,-0.0058480743,-0.020153364,-0.0032805866,0.004248601,0.0051449724,0.006791097,0.007650814,0.003458861,-0.0031223053,-0.01932697,-0.033615597,0.00745088,0.006321252,-0.0038154104,0.014555207,0.027697546,-0.02828402,0.0066711367,0.0077107945,0.01794076,0.011349596,-0.0052715978,0.014755142,-0.019753495,-0.011156326,0.011202978,0.022126047,0.00846388,0.030549942,-0.0041386373,0.018847128,-0.00033655585,0.024925126,-0.003555496,-0.019300312,0.010749794,0.0075308536,-0.018287312,-0.016567878,-0.012869096,-0.015528221,0.0078107617,-0.011156326,0.013522214,-0.020646535,-0.01211601,0.055928253,0.011596181,-0.017247654,0.0005939711,-0.026977783,-0.003942035,-0.009583511,-0.0055248477,-0.028737204,0.023179034,0.003995351,0.0219661,-0.008470545,0.023392297,0.010469886,-0.015874773,0.007890735,-0.009690142,-0.00024970944,0.012775794,0.0114762215,0.013422247,0.010429899,-0.03686786,-0.006717788,-0.027484283,0.011556195,-0.036068123,-0.013915418,-0.0016327957,0.0151016945,-0.020473259,0.004671795,-0.012555866,0.0209531,0.01982014,0.024485271,0.0105431955,-0.005178295,0.033162415,-0.013795458,0.007150979,0.010243294,0.005644808,0.017260984,-0.0045618312,0.0024725192,0.004305249,-0.008197301,0.0014203656,0.0018460588,0.005015015,-0.011142998,0.01439526,0.022965772,0.02552493,0.007757446,-0.0019726837,0.009503538,-0.032042783,0.008403899,-0.04609149,0.013808787,0.011749465,0.036388017,0.016314628,0.021939443,-0.0250051,-0.017354285,-0.012962398,0.00006107364,0.019113706,0.03081652,-0.018114036,-0.0084572155,0.009643491,-0.0034721901,0.0072642746,-0.0090636825,0.01642126,0.013428912,0.027724205,0.0071243206,-0.6858542,-0.031029783,-0.014595194,-0.011449563,0.017514233,0.01743426,0.009950057,0.0029706885,-0.015714826,-0.001806072,0.011856096,0.026444625,-0.0010663156,-0.006474535,0.0016161345,-0.020313311,0.0148351155,-0.0018393943,0.0057347785,0.018300641,-0.018647194,0.03345565,-0.008070676,0.0071443142,0.014301958,0.0044818576,0.003838736,-0.007350913,-0.024525259,-0.001142124,-0.018620536,0.017247654,0.007037683,0.010236629,0.06046009,0.0138887605,-0.012122675,0.037694257,0.0055081863,0.042492677,0.00021784494,-0.011656162,0.010276617,0.022325981,0.005984696,-0.009496873,0.013382261,-0.0010563189,0.0026507939,-0.041639622,0.008637156,0.026471283,-0.008403899,0.024858482,-0.00066686375,-0.0016252982,0.027590916,0.0051449724,0.0058647357,-0.008743787,-0.014968405,0.027724205,-0.011596181,0.0047650975,-0.015381602,0.0043718936,0.002159289,0.035908177,-0.008243952,-0.030443309,0.027564257,0.042625964,-0.0033688906,0.01843393,0.019087048,0.024578573,0.03268257,-0.015608194,-0.014128681,-0.0033538956,-0.0028757197,-0.004121976,-0.032389335,0.0034322033,0.058807302,0.010943064,-0.030523283,0.008903735,0.017500903,0.00871713,-0.0029406983,0.013995391,-0.03132302,-0.019660193,-0.00770413,-0.0038853872,0.0015894766,-0.0015294964,-0.006251275,-0.021099718,-0.010256623,-0.008863748,0.028550599,0.02020668,-0.0012962399,-0.003415542,-0.0022509254,0.0119360695,0.027590916,-0.046971202,-0.0015194997,-0.022405956,0.0016677842,-0.00018535563,-0.015421589,-0.031802863,0.03814744,0.0065411795,0.016567878,-0.015621523,0.022899127,-0.011076353,0.02841731,-0.002679118,-0.002342562,0.015341615,0.01804739,-0.020566562,-0.012989056,-0.002990682,0.01643459,0.00042527664,0.008243952,-0.013715484,-0.004835075,-0.009803439,0.03129636,-0.021432944,0.0012087687,-0.015741484,-0.0052016205,0.00080890034,-0.01755422,0.004811749,-0.017967418,-0.026684547,-0.014128681,0.0041386373,-0.013742141,-0.010056688,-0.013268964,-0.0110630235,-0.028337335,0.015981404,-0.00997005,-0.02424535,-0.013968734,-0.028310679,-0.027750863,-0.020699851,0.02235264,0.001057985,0.00081639783,-0.0099367285,0.013522214,-0.012016043,-0.00086471526,0.013568865,0.0019376953,-0.019020405,0.017460918,-0.023045745,0.008503866,0.0064678704,-0.011509543,0.018727167,-0.003372223,-0.0028690554,-0.0027024434,-0.011902748,-0.012182655,-0.015714826,-0.0098634185,0.00593138,0.018753825,0.0010146659,0.013029044,0.0003521757,-0.017620865,0.04102649,0.00552818,0.024485271,-0.009630162,-0.015608194,0.0006718621,-0.0008418062,0.012395918,0.0057980907,0.016221326,0.010616505,0.004838407,-0.012402583,0.019900113,-0.0034521967,0.000247002,-0.03153628,0.0011038032,-0.020819811,0.016234655,-0.00330058,-0.0032289368,0.00078973995,-0.021952773,-0.022459272,0.03118973,0.03673457,-0.021472929,0.0072109587,-0.015075036,0.004855068,-0.0008151483,0.0069643734,0.010023367,-0.010276617,-0.023019087,0.0068244194,-0.0012520878,-0.0015086699,0.022046074,-0.034148756,-0.0022192693,0.002427534,-0.0027124402,0.0060346797,0.015461575,0.0137554705,0.009230294,-0.009583511,0.032629255,0.015994733,-0.019167023,-0.009203636,0.03393549,-0.017274313,-0.012042701,-0.0009930064,0.026777849,-0.013582194,-0.0027590916,-0.017594207,-0.026804507,-0.0014236979,-0.022032745,0.0091236625,-0.0042419364,-0.00858384,-0.0033905501,-0.020739838,0.016821127,0.022539245,0.015381602,0.015141681,0.028817179,-0.019726837,-0.0051283115,-0.011489551,-0.013208984,-0.0047017853,-0.0072309524,0.01767418,0.0025658219,-0.010323267,0.012609182,-0.028097415,0.026871152,-0.010276617,0.021912785,0.0022542577,0.005124979,-0.0019710176,0.004518512,-0.040360045,0.010969722,-0.0031539614,-0.020366628,-0.025778178,-0.0110030435,-0.016221326,0.0036587953,0.016207997,0.003007343,-0.0032555948,0.0044052163,-0.022046074,-0.0008822095,-0.009363583,0.028230704,-0.024538586,0.0029840174,0.0016044717,-0.014181997,0.031349678,-0.014381931,-0.027750863,0.02613806,0.0004136138,-0.005748107,-0.01868718,-0.0010138329,0.0054348772,0.010703143,-0.003682121,0.0030856507,-0.004275259,-0.010403241,0.021113047,-0.022685863,-0.023032416,0.031429652,0.001792743,-0.005644808,-0.011842767,-0.04078657,-0.0026874484,0.06915057,-0.00056939584,-0.013995391,0.010703143,-0.013728813,-0.022939114,-0.015261642,-0.022485929,0.016807798,0.007964044,0.0144219175,0.016821127,0.0076241563,0.005461535,-0.013248971,0.015301628,0.0085171955,-0.004318578,0.011136333,-0.0059047225,-0.010249958,-0.018207338,0.024645219,0.021752838,0.0007614159,-0.013648839,0.01111634,-0.010503208,-0.0038487327,-0.008203966,-0.00397869,0.0029740208,0.008530525,0.005261601,0.01642126,-0.0038753906,-0.013222313,0.026537929,0.024671877,-0.043505676,0.014195326,0.024778508,0.0056914594,-0.025951454,0.017620865,-0.0021359634,0.008643821,0.021299653,0.0041686273,-0.009017031,0.04044002,0.024378639,-0.027777521,-0.014208655,0.0028623908,0.042119466,0.005801423,-0.028124074,-0.03129636,0.022139376,-0.022179363,-0.04067994,0.013688826,0.013328944,0.0046184794,-0.02828402,-0.0063412455,-0.0046184794,-0.011756129,-0.010383247,-0.0018543894,-0.0018593877,-0.00052024535,0.004815081,0.014781799,0.018007403,0.01306903,-0.020433271,0.009043689,0.033189073,-0.006844413,-0.019766824,-0.018767154,0.00533491,-0.0024575242,0.018727167,0.0058080875,-0.013835444,0.0040719924,0.004881726,0.012029372,0.005664801,0.03193615,0.0058047553,0.002695779,0.009290274,0.02361889,0.017834127,0.0049017193,-0.0036388019,0.010776452,-0.019793482,0.0067777685,-0.014208655,-0.024911797,0.002385881,0.0034988478,0.020899786,-0.0025858153,-0.011849431,0.033189073,-0.021312982,0.024965113,-0.014635181,0.014048708,-0.0035921505,-0.003347231,0.030869836,-0.0017161017,-0.0061346465,0.009203636,-0.025165047,0.0068510775,0.021499587,0.013782129,-0.0024475274,-0.0051149824,-0.024445284,0.006167969,0.0068844,-0.00076183246,0.030150073,-0.0055948244,-0.011162991,-0.02057989,-0.009703471,-0.020646535,0.008004031,0.0066378145,-0.019900113,-0.012169327,-0.01439526,0.0044252095,-0.004018677,0.014621852,-0.025085073,-0.013715484,-0.017980747,0.0071043274,0.011456228,-0.01010334,-0.0035321703,-0.03801415,-0.012036037,-0.0028990454,-0.05419549,-0.024058744,-0.024272008,0.015221654,0.027964126,0.03182952,-0.015354944,0.004855068,0.011522872,0.004771762,0.0027874154,0.023405626,0.0004242353,-0.03132302,0.007057676,0.008763781,-0.0027057757,0.023005757,-0.0071176565,-0.005238275,0.029110415,-0.010989714,0.013728813,-0.009630162,-0.029137073,-0.0049317093,-0.0008630492,-0.015248313,0.0043219104,-0.0055681667,-0.013175662,0.029723546,0.025098402,0.012849103,-0.0009996708,0.03118973,-0.0021709518,0.0260181,-0.020526575,0.028097415,-0.016141351,0.010509873,-0.022965772,0.002865723,0.0020493253,0.0020509914,-0.0041419696,-0.00039695262,0.017287642,0.0038987163,0.014795128,-0.014661839,-0.008950386,0.004431874,-0.009383577,0.0012604183,-0.023019087,0.0029273694,-0.033135757,0.009176978,-0.011023037,-0.002102641,0.02663123,-0.03849399,-0.0044152127,0.0004527676,-0.0026924468,0.02828402,0.017727496,0.035135098,0.02728435,-0.005348239,-0.001467017,-0.019766824,0.014715155,0.011982721,0.0045651635,0.023458943,-0.0010046692,-0.0031373003,-0.0006972704,0.0019043729,-0.018967088,-0.024311995,0.0011546199,0.007977373,-0.004755101,-0.010016702,-0.02780418,-0.004688456,0.013022379,-0.005484861,0.0017227661,-0.015394931,-0.028763862,-0.026684547,0.0030589928,-0.018513903,0.028363993,0.0044818576,-0.009270281,0.038920518,-0.016008062,0.0093902415,0.004815081,-0.021059733,0.01451522,-0.0051583014,0.023765508,-0.017874114,-0.016821127,-0.012522544,-0.0028390652,0.0040886537,0.020259995,-0.031216389,-0.014115352,-0.009176978,0.010303274,0.020313311,0.0064112223,-0.02235264,-0.022872468,0.0052449396,0.0005723116,0.0037321046,0.016807798,-0.018527232,-0.009303603,0.0024858483,-0.0012662497,-0.007110992,0.011976057,-0.007790768,-0.042999174,-0.006727785,-0.011829439,0.007024354,0.005278262,-0.017740825,-0.0041519664,0.0085905045,0.027750863,-0.038387362,0.024391968,0.00087721116,0.010509873,-0.00038508154,-0.006857742,0.0183273,-0.0037054466,0.015461575,0.0017394272,-0.0017944091,0.014181997,-0.0052682655,0.009023695,0.00719763,-0.013522214,0.0034422,0.014941746,-0.0016711164,-0.025298337,-0.017634194,0.0058714002,-0.005321581,0.017834127,0.0110630235,-0.03369557,0.029190388,-0.008943722,0.009363583,-0.0034222065,-0.026111402,-0.007037683,-0.006561173,0.02473852,-0.007084334,-0.010110005,-0.008577175,0.0030439978,-0.022712521,0.0054582027,-0.0012620845,-0.0011954397,-0.015741484,0.0129557345,-0.00042111133,0.00846388,0.008930393,0.016487904,0.010469886,-0.007917393,-0.011762793,-0.0214596,0.000917198,0.021672864,0.010269952,-0.007737452,-0.010243294,-0.0067244526,-0.015488233,-0.021552904,0.017127695,0.011109675,0.038067464,0.00871713,-0.0025591573,0.021312982,-0.006237946,0.034628596,-0.0045251767,0.008357248,0.020686522,0.0010696478,0.0076708077,0.03772091,-0.018700508,-0.0020676525,-0.008923728,-0.023298996,0.018233996,-0.010256623,0.0017860786,0.009796774,-0.00897038,-0.01269582,-0.018527232,0.009190307,-0.02372552,-0.042119466,0.008097334,-0.0066778013,-0.021046404,0.0019593548,0.011083017,-0.0016028056,0.012662497,-0.000059095124,0.0071043274,-0.014675168,0.024831824,-0.053582355,0.038387362,0.0005698124,0.015954746,0.021552904,0.031589597,-0.009230294,-0.0006147976,0.002625802,-0.011749465,-0.034362018,-0.0067844326,-0.018793812,0.011442899,-0.008743787,0.017474247,-0.021619547,0.01831397,-0.009037024,-0.0057247817,-0.02728435,0.010363255,0.034415334,-0.024032086,-0.0020126705,-0.0045518344,-0.019353628,-0.018340627,-0.03129636,-0.0034038792,-0.006321252,-0.0016161345,0.033642255,-0.000056075285,-0.005005019,0.004571828,-0.0024075406,-0.00010215386,0.0098634185,0.1980148,-0.003825407,-0.025191706,0.035161756,0.005358236,0.025111731,0.023485601,0.0023342315,-0.011882754,0.018287312,-0.0068910643,0.003912045,0.009243623,-0.001355387,-0.028603915,-0.012802451,-0.030150073,-0.014795128,-0.028630573,-0.0013487226,0.002667455,0.00985009,-0.0033972147,-0.021486258,0.009503538,-0.017847456,0.013062365,-0.014341944,0.005078328,0.025165047,-0.015594865,-0.025924796,-0.0018177348,0.010996379,-0.02993681,0.007324255,0.014475234,-0.028577257,0.005494857,0.00011725306,-0.013315615,0.015941417,0.009376912,0.0025158382,0.008743787,0.023832154,-0.008084005,-0.014195326,-0.008823762,0.0033455652,-0.032362677,-0.021552904,-0.0056081535,0.023298996,-0.025444955,0.0097301295,0.009736794,0.015274971,-0.0012937407,-0.018087378,-0.0039387033,0.008637156,-0.011189649,-0.00023846315,-0.011582852,0.0066411467,-0.018220667,0.0060846633,0.0376676,-0.002709108,0.0072776037,0.0034188742,-0.010249958,-0.0007747449,-0.00795738,-0.022192692,0.03910712,0.032122757,0.023898797,0.0076241563,-0.007397564,-0.003655463,0.011442899,-0.014115352,-0.00505167,-0.031163072,0.030336678,-0.006857742,-0.022259338,0.004048667,0.02072651,0.0030156737,-0.0042119464,0.00041861215,-0.005731446,0.011103011,0.013822115,0.021512916,0.009216965,-0.006537847,-0.027057758,-0.04054665,0.010403241,-0.0056281467,-0.005701456,-0.002709108,-0.00745088,-0.0024841821,0.009356919,-0.022659205,0.004061996,-0.013175662,0.017074378,-0.006141311,-0.014541878,0.02993681,-0.00028448965,-0.025271678,0.011689484,-0.014528549,0.004398552,-0.017274313,0.0045751603,0.012455898,0.004121976,-0.025458284,-0.006744446,0.011822774,-0.015035049,-0.03257594,0.014675168,-0.0039187097,0.019726837,-0.0047251107,0.0022825818,0.011829439,0.005391558,-0.016781142,-0.0058747325,0.010309938,-0.013049036,0.01186276,-0.0011246296,0.0062112883,0.0028190718,-0.021739509,0.009883412,-0.0073175905,-0.012715813,-0.017181009,-0.016607866,-0.042492677,-0.0014478565,-0.01794076,0.012302616,-0.015194997,-0.04433207,-0.020606548,0.009696807,0.010303274,-0.01694109,-0.004018677,0.019353628,-0.001991011,0.000058938927,0.010536531,-0.17274313,0.010143327,0.014235313,-0.024152048,0.025684876,-0.0012504216,0.036601283,-0.003698782,0.0007310093,0.004165295,-0.0029157067,0.017101036,-0.046891227,-0.017460918,0.022965772,0.020233337,-0.024072073,0.017220996,0.009370248,0.0010363255,0.0194336,-0.019606877,0.01818068,-0.020819811,0.007410893,0.0019326969,0.017887443,0.006651143,0.00067394477,-0.011889419,-0.025058415,-0.008543854,0.021579562,0.0047484366,0.014062037,0.0075508473,-0.009510202,-0.009143656,0.0046817916,0.013982063,-0.0027990784,0.011782787,0.014541878,-0.015701497,-0.029350337,0.021979429,0.01332228,-0.026244693,-0.0123492675,-0.003895384,0.0071576433,-0.035454992,-0.00046984528,0.0033522295,0.039347045,0.0005119148,0.00476843,-0.012995721,0.0024042083,-0.006931051,-0.014461905,-0.0127558,0.0034555288,-0.0074842023,-0.030256703,-0.007057676,-0.00807734,0.007804097,-0.006957709,0.017181009,-0.034575284,-0.008603834,-0.005008351,-0.015834786,0.02943031,0.016861115,-0.0050849924,0.014235313,0.0051449724,0.0025924798,-0.0025741523,0.04289254,-0.002104307,0.012969063,-0.008310596,0.00423194,0.0074975314,0.0018810473,-0.014248641,-0.024725191,0.0151016945,-0.017527562,0.0018727167,0.0002830318,0.015168339,0.0144219175,-0.004048667,-0.004358565,0.011836103,-0.010343261,-0.005911387,0.0022825818,0.0073175905,0.00403867,0.013188991,0.03334902,0.006111321,0.008597169,0.030123414,-0.015474904,0.0017877447,-0.024551915,0.013155668,0.023525586,-0.0255116,0.017220996,0.004358565,-0.00934359,0.0099967085,0.011162991,0.03092315,-0.021046404,-0.015514892,0.0011946067,-0.01816735,0.010876419,-0.10124666,-0.03550831,0.0056348112,0.013942076,0.005951374,0.020419942,-0.006857742,-0.020873128,-0.021259667,0.0137554705,0.0057880944,-0.029163731,-0.018767154,-0.021392956,0.030896494,-0.005494857,-0.0027307675,-0.006801094,-0.014821786,0.021392956,-0.0018110704,-0.0018843795,-0.012362596,-0.0072176233,-0.017194338,-0.018713837,-0.024272008,0.03801415,0.00015880188,0.0044951867,-0.028630573,-0.0014070367,-0.00916365,-0.026537929,-0.009576847,-0.013995391,-0.0077107945,0.0050016865,0.00578143,-0.04467862,0.008363913,0.010136662,-0.0006268769,-0.006591163,0.015341615,-0.027377652,-0.00093136,0.029243704,-0.020886457,-0.01041657,-0.02424535,0.005291591,-0.02980352,-0.009190307,0.019460259,-0.0041286405,0.004801752,0.0011787785,-0.001257086,-0.011216307,-0.013395589,0.00088137644,-0.0051616337,0.03876057,-0.0033455652,0.00075850025,-0.006951045,-0.0062112883,0.018140694,-0.006351242,-0.008263946,0.018154023,-0.012189319,0.0075508473,-0.044358727,-0.0040153447,0.0093302615,-0.010636497,0.032789204,-0.005264933,-0.014235313,-0.018393943,0.007297597,-0.016114693,0.015021721,0.020033404,0.0137688,0.0011046362,0.010616505,-0.0039453674,0.012109346,0.021099718,-0.0072842683,-0.019153694,-0.003768759,0.039320387,-0.006747778,-0.0016852784,0.018154023,0.0010963057,-0.015035049,-0.021033075,-0.04345236,0.017287642,0.016341286,-0.008610498,0.00236922,0.009290274,0.028950468,-0.014475234,-0.0035654926,0.015434918,-0.03372223,0.004501851,-0.012929076,-0.008483873,-0.0044685286,-0.0102233,0.01615468,0.0022792495,0.010876419,-0.0059647025,0.01895376,-0.0069976957,-0.0042952523,0.017207667,-0.00036133936,0.0085905045,0.008084005,0.03129636,-0.016994404,-0.014915089,0.020100048,-0.012009379,-0.006684466,0.01306903,0.00015765642,-0.00530492,0.0005277429,0.015421589,0.015528221,0.032202728,-0.003485519,-0.0014286962,0.033908837,0.001367883,0.010509873,0.025271678,-0.020993087,0.019846799,0.006897729,-0.010216636,-0.00725761,0.01818068,-0.028443968,-0.011242964,-0.014435247,-0.013688826,0.006101324,-0.0022509254,0.013848773,-0.0019077052,0.017181009,0.03422873,0.005324913,-0.0035188415,0.014128681,-0.004898387,0.005038341,0.0012320944,-0.005561502,-0.017847456,0.0008538855,-0.0047884234,0.011849431,0.015421589,-0.013942076,0.0029790192,-0.013702155,0.0001199605,-0.024431955,0.019926772,0.022179363,-0.016487904,-0.03964028,0.0050849924,0.017487574,0.022792496,0.0012504216,0.004048667,-0.00997005,0.0076041627,-0.014328616,-0.020259995,0.0005598157,-0.010469886,0.0016852784,0.01716768,-0.008990373,-0.001987679,0.026417969,0.023792166,0.0046917885,-0.0071909656,-0.00032051947,-0.023259008,-0.009170313,0.02071318,-0.03156294,-0.030869836,-0.006324584,0.013795458,-0.00047151142,0.016874444,0.00947688,0.00985009,-0.029883493,0.024205362,-0.013522214,-0.015075036,-0.030603256,0.029270362,0.010503208,0.021539574,0.01743426,-0.023898797,0.022019416,-0.0068777353,0.027857494,-0.021259667,0.0025758184,0.006197959,0.006447877,-0.00025200035,-0.004941706,-0.021246338,-0.005504854,-0.008390571,-0.0097301295,0.027244363,-0.04446536,0.05216949,0.010243294,-0.016008062,0.0122493,-0.0199401,0.009077012,0.019753495,0.006431216,-0.037960835,-0.027377652,0.016381273,-0.0038620618,0.022512587,-0.010996379,-0.0015211658,-0.0102233,0.007071005,0.008230623,-0.009490209,-0.010083347,0.024431955,0.002427534,0.02828402,0.0035721571,-0.022192692,-0.011882754,0.010056688,0.0011904413,-0.01426197,-0.017500903,-0.00010985966,0.005591492,-0.0077707744,-0.012049366,0.011869425,0.00858384,-0.024698535,-0.030283362,0.020140035,0.011949399,-0.013968734,0.042732596,-0.011649498,-0.011982721,-0.016967745,-0.0060913274,-0.007130985,-0.013109017,-0.009710136}; 25 var options = new VectorSearchOptions<EmbeddedMovie>() { 26 IndexName = "vector_index", 27 NumberOfCandidates = 150 28 }; 29 30 // run query 31 var results = moviesCollection.Aggregate() 32 .VectorSearch(m => m.Embedding, vector, 10, options) 33 .Project(Builders<EmbeddedMovie>.Projection 34 .Include(m => m.Title) 35 .Include(m => m.Plot) 36 .MetaVectorSearchScore(m => m.Score)) 37 .ToList(); 38 39 // print results 40 foreach (var movie in results) 41 { 42 Console.WriteLine(movie.ToJson()); 43 } 44 } 45 } 46 47 [ ]48 public class EmbeddedMovie 49 { 50 [ ]51 public string Title { get; set; } 52 public string Plot { get; set; } 53 [ ]54 public double[] Embedding { get; set; } 55 public double Score { get; set; } 56 }
1 { "_id" : ObjectId("573a13a0f29313caabd04a4f"), "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : 0.78926712274551392 } 2 { "_id" : ObjectId("573a13d8f29313caabda6557"), "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : 0.78436046838760376 } 3 { "_id" : ObjectId("573a13a5f29313caabd13b4b"), "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : 0.78010666370391846 } 4 { "_id" : ObjectId("573a13aef29313caabd2e2d7"), "plot" : "After using his mother's newly built time machine, Dolf gets stuck involuntary in the year 1212. He ends up in a children's crusade where he confronts his new friends with modern techniques...", "title" : "Crusade in Jeans", "score" : 0.77891707420349121 } 5 { "_id" : ObjectId("573a1399f29313caabceec0e"), "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : 0.77716124057769775 } 6 { "_id" : ObjectId("573a1399f29313caabcee36f"), "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : 0.77308857440948486 } 7 { "_id" : ObjectId("573a13c6f29313caabd715d3"), "plot" : "Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.", "title" : "Men in Black 3", "score" : 0.77123808860778809 } 8 { "_id" : ObjectId("573a13d4f29313caabd98c13"), "plot" : "Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.", "title" : "Tomorrowland", "score" : 0.76699239015579224 } 9 { "_id" : ObjectId("573a13b6f29313caabd477fa"), "plot" : "With the help of his uncle, a man travels to the future to try and bring his girlfriend back to life.", "title" : "Love Story 2050", "score" : 0.76493728160858154 } 10 { "_id" : ObjectId("573a13e5f29313caabdc40c9"), "plot" : "A dimension-traveling wizard gets stuck in the 21st century because cell-phone radiation interferes with his magic. With his home world on the brink of war, he seeks help from a jaded ...", "title" : "The Portal", "score" : 0.76407861709594727 }
The following query filters the documents for movies released between
January 01, 1955
and January 01, 1975
before performing the
semantic search against the sample vector data. It uses the
$and
operator to perform a logical AND
operation of the
specified dates. It then searches the plot_embedding
field in the
filtered documents for 150
nearest neighbors using the vector
embeddings for the string kids adventure, and returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include onlyplot
,title
, andyear
fields in the results.Add a field named
score
that shows the vector search score of the documents in the results.
1 using System.Reflection.Emit; 2 using MongoDB.Bson; 3 using MongoDB.Bson.Serialization.Attributes; 4 using MongoDB.Bson.Serialization.Conventions; 5 using MongoDB.Driver; 6 using MongoDB.Driver.Search; 7 8 public class vectorSearchFilterQuery 9 { 10 // define connection to your Atlas cluster 11 private const string MongoConnectionString = "<connection-string>"; 12 13 public static void Main(string[] args){ 14 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() }; 15 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true); 16 17 // connect to your Atlas cluster 18 var mongoClient = new MongoClient(MongoConnectionString); 19 20 // define namespace 21 var moviesDatabase = mongoClient.GetDatabase("sample_mflix"); 22 var moviesCollection = moviesDatabase.GetCollection<EmbeddedMovie>("embedded_movies"); 23 24 // define vector embeddings to search 25 var vector = new[] {0.02421053,-0.022372592,-0.006231137,-0.02168502,-0.020375984,0.037552103,-0.010505334,-0.027026938,0.0070674648,-0.020032197,0.01783725,0.016303431,0.014584498,-0.018736385,0.009031017,-0.0045981496,0.02750295,-0.028322749,0.010624337,-0.024236975,-0.0048659067,0.015153068,-0.000490888,-0.022161031,-0.0024560927,-0.007411252,0.009745035,-0.01886861,0.02112967,-0.011939983,0.015153068,0.0025800543,0.017824028,-0.02410475,-0.016633997,-0.0018214093,-0.008323609,-0.009222744,0.009388026,-0.0028296304,0.0017536436,0.0065517845,-0.011635863,-0.028454976,-0.018934723,0.012951509,-0.0032015154,-0.005880739,-0.03115238,0.012951509,0.0057749585,0.009202911,-0.0069352393,0.00205611,0.0063732797,0.0039700773,-0.007100521,-0.0077087595,0.011596196,-0.010207825,-0.007100521,-0.0051006074,-0.01670011,0.012773004,-0.035304267,-0.0074971984,0.0025800543,-0.006118745,0.030253245,-0.0010751605,0.039456155,0.007821151,-0.0017189344,-0.0010801188,0.0062575825,-0.011490415,-0.022637043,0.004743598,-0.012601111,0.0197413,-0.0015255542,-0.025942687,-0.03284487,0.020389207,0.009797926,0.0141217075,-0.0015172901,0.025982354,-0.011589585,-0.001138794,0.0006131968,0.016832335,0.017916586,0.014412603,-0.0027155858,0.011854036,-0.02169824,0.02112967,-0.020680103,-0.007391418,-0.012872174,0.021473458,0.0047766543,-0.0048394613,-0.024395647,0.0065418677,0.009797926,-0.00449898,0.041836217,0.0023833686,-0.021737909,0.0136721395,0.014148152,-0.028772317,-0.027899627,-0.015695194,-0.012521776,0.02205525,-0.01927851,-0.022068473,0.020971,0.02317917,0.030544141,-0.011827591,0.0075170323,0.023086611,-0.02164535,-0.01732157,0.007510421,-0.027635176,0.016263764,-0.0008801275,0.033109322,-0.014505162,-0.029909458,0.036679417,0.0074971984,0.0059137954,-0.031178825,-0.012634167,0.008416167,0.030491251,-0.016832335,-0.009507029,0.010016099,0.009778093,0.007840985,0.010928456,-0.009685534,-0.027661622,0.024752656,-0.024871659,0.01516629,0.002778393,0.0059501575,0.022042029,0.0005441915,0.0076889256,-0.009883873,-0.019966085,0.008508725,0.0098045375,0.0091169635,-0.02750295,0.012501942,0.03480181,0.021751132,0.020746216,0.003546955,-0.014690278,0.010445832,0.008469057,-0.00007535833,0.0059600743,-0.013526691,0.029539226,-0.011126795,0.025400562,-0.025466675,-0.0046080663,-0.013923368,-0.009011183,0.019318178,0.019053727,-0.012085431,-0.0074707535,0.0013024234,0.0076624807,0.0060460214,-0.0023007276,0.017757915,0.031258162,0.0008768218,-0.003695709,-0.6981518,-0.012058986,0.008931847,-0.02914255,0.00833022,0.028349195,0.013857256,0.0029668147,-0.008164939,-0.001494977,-0.0011197866,0.0104855,0.014610942,-0.0066608707,0.000643774,0.0020676798,0.008607894,-0.023787407,0.020494986,0.015443964,-0.019833859,0.012905231,0.013387854,-0.020918109,0.0035800114,0.026775708,0.005920407,-0.018233927,-0.008759954,0.0005437783,-0.022081695,0.0071996907,-0.002963509,0.004092386,0.057967756,-0.015285294,-0.008978127,0.027740957,0.015853863,0.047178138,-0.018366152,-0.0064889775,0.029777233,0.0141217075,0.007847597,0.02200236,0.031125935,0.010611114,-0.00663112,-0.005940241,0.017215788,-0.019992528,-0.01644888,-0.013447356,0.001490845,0.007893875,0.016276987,-0.0062939445,0.00032333322,0.0020230536,-0.025360893,0.028587202,-0.009645866,0.01459772,-0.012376328,0.03202507,-0.006059244,0.010888788,0.014518384,-0.034405135,0.023364285,0.018895056,-0.009361581,-0.0011255714,0.00663112,0.016885225,0.01609187,-0.006750123,-0.035304267,0.0022660184,0.027714511,0.01680589,-0.03686453,-0.008045935,0.052943178,-0.0091169635,-0.0066840104,0.018405821,0.00027374856,0.0005235312,0.0138969235,0.018075256,0.0005850988,-0.0074971984,0.0011255714,-0.011054071,-0.0022048638,0.0043931995,0.021142893,-0.02472621,-0.007232747,0.0014858865,-0.00062228733,-0.017903363,-0.0013495288,-0.0001454483,0.0027370725,0.0060129645,0.0364943,-0.04601455,-0.008713675,-0.017215788,-0.017784359,-0.007100521,-0.014610942,-0.027978962,0.0046179835,-0.010267328,0.036785197,-0.019542962,0.028719427,0.004343615,0.0067765685,-0.018075256,-0.004462618,0.010121879,-0.0024957606,-0.00883929,0.0017007533,-0.011371412,-0.007788095,0.002418078,-0.01053839,-0.018458711,-0.0048328503,0.0035072872,0.0043568374,-0.006389808,0.027635176,-0.002768476,-0.033479553,-0.0069749067,-0.00096276856,-0.0034048124,0.012773004,-0.01979419,-0.003675875,-0.011655698,-0.026709596,-0.0009206216,-0.009295468,0.011391246,0.0050510224,0.0027486421,0.0024246892,-0.01264739,0.004687402,-0.0058377655,0.0117945345,-0.009388026,0.010545001,0.020481765,-0.000089768866,-0.022425482,-0.013487023,-0.008316998,-0.019503294,0.025942687,0.0076889256,-0.03355889,-0.0071071326,-0.019106617,-0.015430742,0.021724686,0.0019652047,0.011113572,-0.019410737,-0.023615515,0.000523118,0.019027282,-0.015853863,-0.011887092,-0.021804022,-0.013473801,-0.0049518533,-0.00071773777,-0.003194904,0.046411227,-0.0108689545,0.04003795,-0.0026626955,0.03146972,-0.005804709,-0.013645695,0.0046973187,-0.010148324,0.02292794,0.0310466,0.018709939,0.020005751,0.028534312,-0.02134123,0.044031166,-0.00021548661,0.018458711,-0.038795028,-0.00930208,-0.013738252,0.029486336,-0.0019503294,0.008812845,-0.02755584,0.004852684,-0.013301908,0.000006940559,0.017453795,-0.005249361,0.0069352393,-0.023205614,-0.02040243,-0.0060493266,-0.017110009,0.011417692,0.006882349,-0.019556185,0.015893532,-0.0028874793,-0.0023387424,-0.0034610082,-0.009427694,-0.009705368,0.002194947,-0.008191383,0.021804022,-0.016250541,0.0053320024,0.037393436,-0.014174597,0.031073045,0.004108914,0.010029321,0.018538047,0.007675703,-0.012568055,-0.0080525465,0.0013487024,0.03234241,-0.009983042,-0.014782836,0.0069418503,-0.014346491,-0.0009875608,-0.024924548,0.035145596,0.009592976,-0.010902011,0.0047568204,0.006194775,0.011344967,0.028349195,0.0062410543,-0.0027172386,0.011080516,0.012303604,0.012263936,-0.009844205,-0.004766737,-0.0062079974,-0.005748513,-0.01979419,-0.006036104,-0.018630605,-0.00050204457,-0.013830811,0.0015338184,-0.00418825,-0.020799106,-0.016792666,-0.0034015067,0.034352243,0.00915002,-0.019767746,0.016462103,0.014346491,-0.009672312,-0.032606862,-0.010035932,-0.0035238154,-0.018934723,0.012204434,-0.015946422,0.022597376,-0.00081194856,0.002740378,0.0088921795,0.0056361216,0.011549917,-0.0088789575,0.008720286,0.007424474,-0.0022263506,0.0020131366,-0.023165947,-0.037181873,0.014756391,0.011424302,-0.0057385964,-0.014690278,-0.018709939,-0.005536952,-0.0064228643,0.00418825,-0.023787407,0.012845729,-0.009487196,-0.011754867,-0.008746731,-0.013844033,0.026643483,0.009070684,-0.016554661,-0.024078304,-0.013553137,0.011146628,0.11075226,-0.007854208,0.0024098137,0.005685706,0.0032081266,-0.00603941,-0.022161031,0.0004933672,0.0014486981,-0.001134662,0.007345139,0.008237663,-0.0019057032,0.007120355,-0.009864039,0.03115238,-0.00041051954,-0.00344448,-0.013063901,-0.020997444,0.013222572,-0.002824672,0.018366152,0.025889797,0.007523644,-0.019648742,-0.007391418,0.02168502,-0.0019255371,-0.018524824,-0.00021156116,-0.004826239,-0.001088383,-0.0071468004,0.0000106013,-0.002963509,0.015430742,0.029036768,0.035806727,-0.016924892,0.039271038,0.02503033,0.019648742,-0.02636581,0.0035634832,-0.00044254295,-0.016435657,0.012792839,0.008270719,-0.03469603,0.052599393,0.008270719,-0.0052824174,-0.0059534633,0.023668405,0.011159851,-0.018128147,-0.0064856717,0.009606198,-0.015258849,0.00291723,-0.028851653,0.019133061,-0.012323437,-0.01516629,-0.027846737,-0.019820636,0.0024974134,-0.01377792,-0.00067063235,-0.022703156,-0.009156631,-0.012303604,-0.023311395,0.006174941,0.0073980293,0.012343272,-0.015721638,-0.00033097752,0.019146284,0.011761478,-0.019542962,-0.0057452074,-0.0076823146,-0.002343701,0.007840985,0.014941507,0.007847597,-0.004029579,0.008812845,0.029168995,0.01876283,0.01125902,-0.010611114,0.00021734604,-0.0037948783,-0.0016445575,0.028587202,0.015086955,0.0035899284,0.0009900401,-0.019622298,-0.00704102,-0.0062410543,0.0027106274,0.009652478,-0.01573486,0.0152985165,0.0046774847,-0.02595591,0.0115565285,-0.021989137,0.010961512,-0.011179685,0.011781312,-0.00055782724,-0.0033238241,-0.0012619293,0.02066688,-0.014372936,0.006399725,-0.022332925,0.011014403,0.01927851,-0.008733509,0.003798184,0.017744692,-0.036732305,0.0077087595,0.005454311,-0.0038676024,0.01696456,-0.00037973575,0.0058212373,-0.030517697,-0.012006096,0.012482109,0.015946422,0.0031899456,0.001283416,-0.0055898423,0.01737446,0.03633563,0.015642302,-0.002953592,-0.02446176,-0.011364801,-0.023033721,-0.003798184,0.03726121,-0.021513125,0.014505162,-0.008971515,-0.0023007276,0.0009231008,-0.03916526,-0.023364285,0.008145104,0.020997444,0.025889797,0.0302268,-0.02107678,0.03720832,-0.009936763,0.013361409,-0.00080492406,-0.015972868,-0.0035172042,-0.041968442,0.012369717,0.020389207,0.011530083,0.0016420782,-0.026947603,0.010465666,0.009983042,0.011549917,-0.013923368,-0.0075699226,-0.012442441,0.0031635005,-0.0003237464,-0.009196299,0.007920321,-0.003556872,0.0043105586,0.036520746,0.0029155773,-0.0025073302,-0.016224096,0.0094541395,-0.016409213,0.01192676,0.0008702105,0.014796059,0.002148668,-0.013414299,-0.026154248,-0.02235937,0.011801146,0.012442441,-0.0016685233,0.008898791,0.0063931136,-0.01094829,0.013963036,0.002611458,-0.015880309,0.01789014,-0.0050378,-0.0035800114,-0.016885225,0.0073120827,-0.040117282,0.005748513,0.0027536007,-0.022676712,0.008674008,-0.024699764,0.0045783157,-0.030676367,0.0008602936,0.038742136,0.010551613,0.020812329,0.0017354626,0.011278854,-0.0068559037,-0.016686887,-0.007424474,0.0022759351,0.014452271,0.0141217075,0.0020296648,-0.0016784403,-0.017810805,-0.009526864,-0.015906755,-0.012092043,0.0143597135,-0.009090519,0.01352008,-0.012620945,-0.008270719,-0.013288685,0.027978962,-0.0049882154,-0.0044791466,-0.008726898,-0.015946422,-0.02153957,0.012938287,-0.016753,0.022531264,0.015933199,-0.013361409,0.03834546,-0.001832979,-0.008773177,-0.012111876,-0.02524189,0.024792323,0.009758258,0.029327665,0.01141108,0.01022766,-0.016726553,0.008409556,0.011424302,0.023192393,0.0021354454,-0.01346719,-0.016435657,0.0051072184,-0.0037485992,-0.015338183,-0.009374804,-0.02251804,-0.026815377,-0.022703156,0.01582742,0.016951337,-0.014491939,-0.011523472,-0.018154591,0.0061418847,-0.00039378472,-0.009599588,0.00061898166,-0.026088135,-0.010809453,-0.012680447,0.0011892051,0.00817155,-0.011060682,-0.007834374,-0.0015015884,0.018974392,-0.026379032,0.01794303,-0.029063214,0.005731985,-0.015721638,0.013202738,0.018855387,-0.017043896,0.021883357,-0.00976487,-0.0063501406,0.0006817889,-0.021010667,-0.0034411745,-0.019701632,-0.015999312,-0.0065418677,0.0036130678,-0.015615858,-0.017519908,-0.035330713,0.029486336,0.0007094736,-0.015351406,-0.00010252659,-0.0019618992,0.02565179,0.0023751045,0.024382424,-0.007807929,-0.016157983,-0.008012879,-0.0076823146,0.020256981,-0.0023784102,-0.01125902,-0.017229011,-0.009163243,-0.0073980293,0.018802498,0.0007470753,0.004786571,0.038133897,0.022782492,0.0136721395,0.0048394613,-0.00033986144,0.0070608538,0.005771653,-0.026167471,-0.021394122,-0.0039237984,0.01922562,0.03868925,0.00899796,-0.021658573,-0.010809453,-0.010604503,-0.011966428,0.0051733316,0.003074248,0.017757915,0.051620923,0.0036593468,-0.016673664,0.013024233,0.004826239,0.02750295,-0.00817155,-0.012865563,0.013037456,0.01758602,-0.0006045195,0.010187992,-0.03263331,-0.015814196,0.029274775,0.0018957863,-0.009672312,0.0011966428,-0.015748084,-0.0054972842,-0.041386653,0.012250713,0.007530255,0.0047204583,0.018286817,-0.02134123,0.0033915897,-0.007391418,-0.0035304269,-0.0032180436,-0.0002681703,-0.009361581,-0.013249017,0.02036276,-0.010749951,-0.02107678,-0.017242234,-0.01644888,0.02483199,-0.0060823835,0.0042576683,0.020071864,0.014372936,-0.013963036,-0.008350055,0.005474145,-0.0029321054,-0.029512782,-0.023046944,-0.017718246,0.0016106745,-0.021618906,-0.011490415,-0.009209521,0.009282245,0.01459772,0.024567539,-0.0021073474,0.02168502,0.0021040419,-0.025770793,0.0014296906,0.0042279176,-0.009553309,-0.0041254424,-0.012396161,0.0018395904,-0.016753,-0.0076889256,-0.0010991263,-0.022782492,0.004224612,0.014518384,0.015100177,-0.01315646,0.0036362074,0.19643453,-0.006902183,-0.01223088,0.0163431,-0.0065352563,0.018723162,0.0247791,-0.0050807735,-0.0047832653,-0.009196299,-0.014928284,0.027529396,0.0019933027,0.0026180693,0.0016205915,-0.01639599,-0.02153957,-0.017202567,-0.024131194,-0.03316221,-0.00085698796,-0.0063600573,-0.03181351,-0.009037628,0.0032907678,-0.0050378,-0.0010346663,-0.01835293,0.01361925,0.026088135,0.0005751819,-0.016819112,-0.009434305,0.0023354369,-0.020997444,-0.0067402064,0.008310387,0.0040626354,0.0040890803,0.030306136,-0.015959645,0.021037113,-0.0009916929,0.0070872987,-0.01161603,0.017096786,-0.001370189,-0.0042080837,0.0008140146,0.014108485,-0.02606169,-0.010472277,0.021261897,0.019966085,-0.011735033,-0.010908622,0.0016586065,0.029697897,-0.01830004,-0.011034236,-0.0038246291,0.031787064,-0.0079401545,0.0075500887,-0.009844205,0.022161031,-0.0044097276,0.0059600743,0.011959816,-0.019371068,0.0037915725,-0.015020842,-0.010968124,-0.0062741106,-0.00012179228,-0.027053382,0.03377045,0.005725374,0.0026891406,-0.0011602807,-0.00403619,-0.0076889256,0.0040791635,-0.0040989975,-0.018895056,-0.0197413,0.014756391,0.0057914867,-0.012296992,-0.017757915,0.008422779,-0.020137977,0.003537038,-0.0011040848,0.0061286623,0.031734172,-0.011748255,0.03207796,0.008204606,-0.0043270867,-0.02652448,-0.03501337,0.0050609396,0.015615858,-0.027476504,0.0026660012,0.00057104987,0.022861827,-0.012098653,-0.0024461758,0.01022766,-0.008350055,0.0114441365,0.0022081695,-0.0044130334,0.018009143,-0.0013867173,-0.016620774,-0.0060460214,-0.01459772,0.008164939,-0.013249017,0.005748513,0.005232833,-0.024950994,-0.011490415,-0.013480413,0.021552794,0.011285465,-0.03604473,0.0041915555,-0.0052096937,0.013037456,-0.012449052,-0.013037456,0.01639599,0.0051997765,-0.002267671,0.015047288,0.018643826,0.013976259,0.0052394443,0.0059534633,0.010016099,-0.0016528215,-0.03670586,0.023483288,0.008250885,-0.0051997765,-0.012607723,-0.019133061,-0.005798098,-0.012991177,-0.001120613,0.015272071,-0.03279198,-0.040646188,-0.014994397,-0.009031017,0.014108485,-0.011424302,0.021420566,0.0053353077,0.0052361386,-0.012607723,-0.0076823146,-0.17136453,-0.0011024319,0.011351578,-0.0062278314,0.008700453,0.0017106703,0.011992873,0.0048758234,-0.004568399,-0.0052460553,0.02729139,-0.013407689,-0.041809775,0.0023552708,0.025612123,0.031337496,-0.008925236,0.017004227,0.013989481,0.005252667,0.02344362,0.023879966,-0.0006917058,0.013949813,0.0005198124,0.0051072184,0.0040791635,0.0046576513,-0.012574666,-0.013698584,-0.012654002,-0.00344448,-0.006862515,0.012944899,0.023324618,0.004743598,-0.029724343,0.006307167,0.0016453839,0.0093549695,-0.008469057,0.035648055,0.01454483,-0.0115697505,0.011344967,0.015496855,-0.013738252,-0.0026610426,-0.005923712,-0.007953377,0.01609187,-0.02698727,0.011483804,-0.014796059,0.024408868,0.009778093,-0.0014437396,0.007001352,0.022068473,-0.011701977,-0.00007365386,-0.023377508,0.012964732,-0.010445832,-0.018114924,-0.04009084,-0.0056427326,0.0071269665,-0.03300354,0.028666537,-0.025850128,-0.017440572,0.007966599,-0.026484812,0.012409384,-0.0022032112,-0.009778093,-0.005798098,-0.015430742,-0.0028775623,-0.011629253,0.035304267,-0.03295065,0.019384291,-0.009513641,0.017387683,-0.019873526,-0.011113572,-0.012052375,-0.010531778,0.010459054,-0.034458023,-0.01876283,-0.00026589766,0.008217828,0.025202222,0.0009792967,-0.005712151,0.005150192,-0.01794303,-0.0048956573,-0.010895399,-0.007345139,-0.005725374,0.036917422,-0.009447528,0.042603128,0.017969476,0.03094082,-0.0061617186,0.01459772,0.0040031336,0.004340309,0.01979419,-0.0055799256,0.020349538,-0.019040504,-0.019648742,0.019780967,-0.0012842424,0.03839835,-0.0005590669,-0.023165947,-0.011067293,0.014015927,0.012303604,-0.10461699,-0.009315303,0.00067393796,0.021195784,-0.017506685,0.009427694,0.0045055915,0.00096194213,0.015919978,0.016435657,-0.014095262,0.0028676454,-0.004730375,-0.0136721395,0.010306995,-0.0073186937,-0.013401077,-0.0090045715,-0.019344624,0.009242578,-0.016686887,0.0007702148,0.012528387,-0.012025929,-0.022689935,-0.009976431,-0.032236632,0.02750295,0.004158499,0.01855127,0.002371799,-0.0053320024,0.007715371,-0.03252753,-0.013500246,0.011973039,-0.008469057,-0.0022924636,0.0213809,-0.04842106,0.018895056,0.0015858823,0.007576534,-0.024964217,0.014994397,0.0020412346,-0.005249361,0.0014792753,0.009348359,-0.03638852,-0.028402084,-0.01084251,-0.019979307,-0.0035304269,0.0036064566,-0.014994397,0.017652133,0.01305729,0.007907098,0.006667482,0.0028676454,-0.020005751,-0.012991177,0.03001524,-0.00046609566,0.015615858,-0.02935411,-0.0009925193,0.033796895,-0.019040504,-0.014901839,0.009533474,-0.010121879,0.026458368,-0.038054563,0.009956597,-0.0030048296,-0.0019519823,0.016872002,-0.001142926,-0.014941507,-0.02930122,0.004611372,-0.029512782,0.030887928,-0.0018015754,0.010624337,-0.0044791466,-0.007993045,-0.0056790947,0.0019602464,0.011173073,0.0023222142,-0.00022499033,0.0024511344,0.015443964,0.018987615,-0.02349651,-0.008740121,0.00029730127,-0.004750209,-0.017969476,-0.06442037,0.006816236,0.0019833858,0.0063038613,-0.0054675336,-0.01161603,0.032818425,-0.030094575,0.009685534,-0.0012520123,-0.0013090346,0.0085285595,0.015959645,-0.0006574098,-0.00688896,-0.019133061,-0.0008057505,0.009672312,0.019913195,0.008145104,-0.012290381,0.0016139803,0.026405476,0.014875393,-0.002168502,0.012792839,-0.011840814,0.003464314,0.0069682957,-0.0073781954,0.018842166,-0.03165484,-0.017242234,0.006789791,-0.009130186,-0.012263936,-0.015258849,0.0036692638,0.008865735,0.0272385,-0.004009745,-0.017612467,0.022584153,-0.023760963,0.004231223,0.004287419,-0.020891665,0.022425482,0.007986434,-0.0030345803,0.010459054,0.013844033,0.012283769,-0.027899627,-0.006250971,-0.023430398,0.0122573245,-0.004128748,0.013830811,-0.016766222,0.022861827,-0.011192908,0.03665297,-0.00212057,-0.009031017,-0.024170863,-0.0010230965,-0.0064393925,0.014015927,-0.005956769,0.000146378,-0.008436001,0.010604503,0.013169682,-0.00516672,0.0012321784,-0.022332925,-0.0022643656,-0.03993217,0.02050821,0.01577453,-0.0043667546,-0.022372592,-0.001152843,0.010002876,0.0036262905,-0.017876917,0.006406336,-0.009401249,0.019569406,-0.03033258,-0.01269367,0.0020412346,0.009989654,-0.0014627471,0.04101642,0.0011189602,-0.023046944,0.0013230836,0.024250198,0.01207882,-0.0062377485,-0.010452444,-0.020825552,0.006693927,-0.005305557,-0.018339708,-0.041307315,-0.012296992,0.0070542423,0.0019371068,0.0117945345,-0.020032197,0.017797582,-0.015443964,0.00537167,-0.00015474542,-0.0117747,-0.011140017,0.017334793,0.016250541,0.006019576,0.017612467,-0.017982699,0.010366497,0.0029949127,0.015086955,-0.000027813887,-0.008660785,-0.008713675,-0.0050873845,-0.0117945345,-0.016118316,-0.0022015583,0.006518728,-0.0047766543,0.0055501745,0.039747052,-0.034061346,0.049425974,0.0023883271,-0.0035601775,0.00863434,-0.003897353,0.016237319,0.006436087,-0.00037828952,-0.017797582,-0.019450404,0.0009809496,0.0036461244,0.013176293,0.0036461244,-0.01094829,-0.018260373,0.00035246418,0.012885396,-0.006796402,-0.015972868,0.027899627,-0.0077021485,0.027608732,0.01696456,-0.0014486981,-0.017969476,0.015642302,-0.00477996,-0.0048890463,-0.020058641,0.008323609,0.013017623,-0.01886861,-0.008204606,0.016303431,-0.010029321,-0.001018138,-0.0332151,0.010525168,0.032871313,0.011549917,0.010928456,-0.014253933,-0.011384634,0.00894507,0.034616694,-0.016872002,-0.010987958,-0.011953205}; 26 // define filter 27 var yearGtFilter = Builders<EmbeddedMovie>.Filter.Gt("year", 1955); 28 var yearLtFilter = Builders<EmbeddedMovie>.Filter.Lt("year", 1975); 29 // define options 30 var options = new VectorSearchOptions<EmbeddedMovie>() { 31 Filter = Builders<EmbeddedMovie>.Filter.And(yearGtFilter, yearLtFilter), 32 IndexName = "vector_index", 33 NumberOfCandidates = 150 34 }; 35 36 // run query 37 var results = moviesCollection.Aggregate() 38 .VectorSearch(m => m.Embedding, vector, 10, options) 39 .Project(Builders<EmbeddedMovie>.Projection 40 .Include(m => m.Title) 41 .Include(movie => movie.Plot) 42 .Include(movie => movie.Year) 43 .MetaVectorSearchScore(m => m.Score)) 44 .ToList(); 45 46 // print results 47 foreach (var movie in results) 48 { 49 Console.WriteLine(movie.ToJson()); 50 } 51 } 52 } 53 54 [ ]55 public class EmbeddedMovie 56 { 57 [ ]58 public string Title { get; set; } 59 public string Plot { get; set; } 60 public int Year { get; set; } 61 [ ]62 public double[] Embedding { get; set; } 63 public double Score { get; set; } 64 }
1 { "_id" : ObjectId("573a1395f29313caabce143b"), "plot" : "In this magical tale about the boy who refuses to grow up, Peter Pan and his mischievous fairy sidekick Tinkerbell visit the nursery of Wendy, Michael, and John Darling. With a sprinkling ...", "title" : "Peter Pan", "year" : 1960, "score" : 0.74811083078384399 } 2 { "_id" : ObjectId("573a1396f29313caabce34d3"), "plot" : "A down-on-his-luck inventor turns a broken-down Grand Prix car into a fancy vehicle for his children, and then they go off on a magical fantasy adventure to save their grandfather in a far-off land.", "title" : "Chitty Chitty Bang Bang", "year" : 1968, "score" : 0.74424654245376587 } 3 { "_id" : ObjectId("573a1395f29313caabce23cb"), "plot" : "A young man comes to the rescue of his girlfriend abducted by thieves and brought to Rio. An extravagant adventure ensues.", "title" : "That Man from Rio", "year" : 1964, "score" : 0.74160200357437134 } 4 { "_id" : ObjectId("573a1396f29313caabce5648"), "plot" : "A pilot, stranded in the desert, meets a little boy who is a prince on a planet.", "title" : "The Little Prince", "year" : 1974, "score" : 0.73789441585540771 } 5 { "_id" : ObjectId("573a1394f29313caabce000d"), "plot" : "A red balloon with a life of its own follows a little boy around the streets of Paris.", "title" : "The Red Balloon", "year" : 1956, "score" : 0.73427128791809082 } 6 { "_id" : ObjectId("573a1396f29313caabce482f"), "plot" : "A poor boy wins the opportunity to tour the most eccentric and wonderful candy factory of all.", "title" : "Willy Wonka & the Chocolate Factory", "year" : 1971, "score" : 0.7342107892036438 } 7 { "_id" : ObjectId("573a1396f29313caabce43e1"), "plot" : "An apprentice witch, three kids and a cynical conman search for the missing component to a magic spell useful to the defense of Britain.", "title" : "Bedknobs and Broomsticks", "year" : 1971, "score" : 0.7339356541633606 } 8 { "_id" : ObjectId("573a1396f29313caabce54e6"), "plot" : "A young boys' coming of age tale set in a strange, carnivalesque village becomes the recreation of a memory that the director has twenty years later.", "title" : "Pastoral Hide and Seek", "year" : 1974, "score" : 0.73329997062683105 } 9 { "_id" : ObjectId("573a1396f29313caabce582d"), "plot" : "A young swordsman comes to Paris and faces villains, romance, adventure and intrigue with three Musketeer friends.", "title" : "The Three Musketeers", "year" : 1973, "score" : 0.73311984539031982 } 10 { "_id" : ObjectId("573a1395f29313caabce243e"), "plot" : "A fairy-tale about a conceited young man and a young woman with a tyrannical step-mother, who must overcome magical trials in order to be together.", "title" : "Frosty", "year" : 1964, "score" : 0.73183083534240723 }
Atlas Vector Search filters the documents based on the year
field value that
ranges between 1955 and 1975. It returns documents that summarize
children's adventures in the plot for movies released between 1955 and
1975.
Tip
See also: Additional Filter Examples
The How to Perform Semantic Search Against Data in Your Atlas Cluster tutorial demonstrates other
pre-filters in semantic search queries against the embedded data in
the sample_mflix.embedded_movies
collection.
The following query uses the $vectorSearch
stage to search
the plot_embedding
field using vector embeddings for the string
time travel. It considers up to 150
nearest neighbors, and
returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include only theplot
andtitle
fields in the results.Add a field named
score
that shows the vector search score for each document in the results.
1 import static com.mongodb.client.model.Aggregates.*; 2 import static com.mongodb.client.model.Projections.*; 3 import static com.mongodb.client.model.search.SearchPath.fieldPath; 4 import static java.util.Arrays.asList; 5 import com.mongodb.client.MongoClient; 6 import com.mongodb.client.MongoClients; 7 import com.mongodb.client.MongoCollection; 8 import com.mongodb.client.MongoDatabase; 9 import java.util.List; 10 import com.mongodb.client.model.search.FieldSearchPath; 11 import org.bson.Document; 12 import org.bson.conversions.Bson; 13 14 public class BasicQuery { 15 public static void main( String[] args ) { 16 // specify connection 17 String uri = "<connection-string>"; 18 19 // establish connection and set namespace 20 try (MongoClient mongoClient = MongoClients.create(uri)) { 21 MongoDatabase database = mongoClient.getDatabase("sample_mflix"); 22 MongoCollection<Document> collection = database.getCollection("embedded_movies"); 23 24 // define $vectorSearch query options 25 List<Double> queryVector = (asList(-0.0016261312d, -0.028070757d, -0.011342932d, -0.012775794d, -0.0027440966d, 0.008683807d, -0.02575152d, -0.02020668d, -0.010283281d, -0.0041719596d, 0.021392956d, 0.028657231d, -0.006634482d, 0.007490867d, 0.018593878d, 0.0038187427d, 0.029590257d, -0.01451522d, 0.016061379d, 0.00008528442d, -0.008943722d, 0.01627464d, 0.024311995d, -0.025911469d, 0.00022596726d, -0.008863748d, 0.008823762d, -0.034921836d, 0.007910728d, -0.01515501d, 0.035801545d, -0.0035688248d, -0.020299982d, -0.03145631d, -0.032256044d, -0.028763862d, -0.0071576433d, -0.012769129d, 0.012322609d, -0.006621153d, 0.010583182d, 0.024085402d, -0.001623632d, 0.007864078d, -0.021406285d, 0.002554159d, 0.012229307d, -0.011762793d, 0.0051682983d, 0.0048484034d, 0.018087378d, 0.024325324d, -0.037694257d, -0.026537929d, -0.008803768d, -0.017767483d, -0.012642504d, -0.0062712682d, 0.0009771782d, -0.010409906d, 0.017754154d, -0.004671795d, -0.030469967d, 0.008477209d, -0.005218282d, -0.0058480743d, -0.020153364d, -0.0032805866d, 0.004248601d, 0.0051449724d, 0.006791097d, 0.007650814d, 0.003458861d, -0.0031223053d, -0.01932697d, -0.033615597d, 0.00745088d, 0.006321252d, -0.0038154104d, 0.014555207d, 0.027697546d, -0.02828402d, 0.0066711367d, 0.0077107945d, 0.01794076d, 0.011349596d, -0.0052715978d, 0.014755142d, -0.019753495d, -0.011156326d, 0.011202978d, 0.022126047d, 0.00846388d, 0.030549942d, -0.0041386373d, 0.018847128d, -0.00033655585d, 0.024925126d, -0.003555496d, -0.019300312d, 0.010749794d, 0.0075308536d, -0.018287312d, -0.016567878d, -0.012869096d, -0.015528221d, 0.0078107617d, -0.011156326d, 0.013522214d, -0.020646535d, -0.01211601d, 0.055928253d, 0.011596181d, -0.017247654d, 0.0005939711d, -0.026977783d, -0.003942035d, -0.009583511d, -0.0055248477d, -0.028737204d, 0.023179034d, 0.003995351d, 0.0219661d, -0.008470545d, 0.023392297d, 0.010469886d, -0.015874773d, 0.007890735d, -0.009690142d, -0.00024970944d, 0.012775794d, 0.0114762215d, 0.013422247d, 0.010429899d, -0.03686786d, -0.006717788d, -0.027484283d, 0.011556195d, -0.036068123d, -0.013915418d, -0.0016327957d, 0.0151016945d, -0.020473259d, 0.004671795d, -0.012555866d, 0.0209531d, 0.01982014d, 0.024485271d, 0.0105431955d, -0.005178295d, 0.033162415d, -0.013795458d, 0.007150979d, 0.010243294d, 0.005644808d, 0.017260984d, -0.0045618312d, 0.0024725192d, 0.004305249d, -0.008197301d, 0.0014203656d, 0.0018460588d, 0.005015015d, -0.011142998d, 0.01439526d, 0.022965772d, 0.02552493d, 0.007757446d, -0.0019726837d, 0.009503538d, -0.032042783d, 0.008403899d, -0.04609149d, 0.013808787d, 0.011749465d, 0.036388017d, 0.016314628d, 0.021939443d, -0.0250051d, -0.017354285d, -0.012962398d, 0.00006107364d, 0.019113706d, 0.03081652d, -0.018114036d, -0.0084572155d, 0.009643491d, -0.0034721901d, 0.0072642746d, -0.0090636825d, 0.01642126d, 0.013428912d, 0.027724205d, 0.0071243206d, -0.6858542d, -0.031029783d, -0.014595194d, -0.011449563d, 0.017514233d, 0.01743426d, 0.009950057d, 0.0029706885d, -0.015714826d, -0.001806072d, 0.011856096d, 0.026444625d, -0.0010663156d, -0.006474535d, 0.0016161345d, -0.020313311d, 0.0148351155d, -0.0018393943d, 0.0057347785d, 0.018300641d, -0.018647194d, 0.03345565d, -0.008070676d, 0.0071443142d, 0.014301958d, 0.0044818576d, 0.003838736d, -0.007350913d, -0.024525259d, -0.001142124d, -0.018620536d, 0.017247654d, 0.007037683d, 0.010236629d, 0.06046009d, 0.0138887605d, -0.012122675d, 0.037694257d, 0.0055081863d, 0.042492677d, 0.00021784494d, -0.011656162d, 0.010276617d, 0.022325981d, 0.005984696d, -0.009496873d, 0.013382261d, -0.0010563189d, 0.0026507939d, -0.041639622d, 0.008637156d, 0.026471283d, -0.008403899d, 0.024858482d, -0.00066686375d, -0.0016252982d, 0.027590916d, 0.0051449724d, 0.0058647357d, -0.008743787d, -0.014968405d, 0.027724205d, -0.011596181d, 0.0047650975d, -0.015381602d, 0.0043718936d, 0.002159289d, 0.035908177d, -0.008243952d, -0.030443309d, 0.027564257d, 0.042625964d, -0.0033688906d, 0.01843393d, 0.019087048d, 0.024578573d, 0.03268257d, -0.015608194d, -0.014128681d, -0.0033538956d, -0.0028757197d, -0.004121976d, -0.032389335d, 0.0034322033d, 0.058807302d, 0.010943064d, -0.030523283d, 0.008903735d, 0.017500903d, 0.00871713d, -0.0029406983d, 0.013995391d, -0.03132302d, -0.019660193d, -0.00770413d, -0.0038853872d, 0.0015894766d, -0.0015294964d, -0.006251275d, -0.021099718d, -0.010256623d, -0.008863748d, 0.028550599d, 0.02020668d, -0.0012962399d, -0.003415542d, -0.0022509254d, 0.0119360695d, 0.027590916d, -0.046971202d, -0.0015194997d, -0.022405956d, 0.0016677842d, -0.00018535563d, -0.015421589d, -0.031802863d, 0.03814744d, 0.0065411795d, 0.016567878d, -0.015621523d, 0.022899127d, -0.011076353d, 0.02841731d, -0.002679118d, -0.002342562d, 0.015341615d, 0.01804739d, -0.020566562d, -0.012989056d, -0.002990682d, 0.01643459d, 0.00042527664d, 0.008243952d, -0.013715484d, -0.004835075d, -0.009803439d, 0.03129636d, -0.021432944d, 0.0012087687d, -0.015741484d, -0.0052016205d, 0.00080890034d, -0.01755422d, 0.004811749d, -0.017967418d, -0.026684547d, -0.014128681d, 0.0041386373d, -0.013742141d, -0.010056688d, -0.013268964d, -0.0110630235d, -0.028337335d, 0.015981404d, -0.00997005d, -0.02424535d, -0.013968734d, -0.028310679d, -0.027750863d, -0.020699851d, 0.02235264d, 0.001057985d, 0.00081639783d, -0.0099367285d, 0.013522214d, -0.012016043d, -0.00086471526d, 0.013568865d, 0.0019376953d, -0.019020405d, 0.017460918d, -0.023045745d, 0.008503866d, 0.0064678704d, -0.011509543d, 0.018727167d, -0.003372223d, -0.0028690554d, -0.0027024434d, -0.011902748d, -0.012182655d, -0.015714826d, -0.0098634185d, 0.00593138d, 0.018753825d, 0.0010146659d, 0.013029044d, 0.0003521757d, -0.017620865d, 0.04102649d, 0.00552818d, 0.024485271d, -0.009630162d, -0.015608194d, 0.0006718621d, -0.0008418062d, 0.012395918d, 0.0057980907d, 0.016221326d, 0.010616505d, 0.004838407d, -0.012402583d, 0.019900113d, -0.0034521967d, 0.000247002d, -0.03153628d, 0.0011038032d, -0.020819811d, 0.016234655d, -0.00330058d, -0.0032289368d, 0.00078973995d, -0.021952773d, -0.022459272d, 0.03118973d, 0.03673457d, -0.021472929d, 0.0072109587d, -0.015075036d, 0.004855068d, -0.0008151483d, 0.0069643734d, 0.010023367d, -0.010276617d, -0.023019087d, 0.0068244194d, -0.0012520878d, -0.0015086699d, 0.022046074d, -0.034148756d, -0.0022192693d, 0.002427534d, -0.0027124402d, 0.0060346797d, 0.015461575d, 0.0137554705d, 0.009230294d, -0.009583511d, 0.032629255d, 0.015994733d, -0.019167023d, -0.009203636d, 0.03393549d, -0.017274313d, -0.012042701d, -0.0009930064d, 0.026777849d, -0.013582194d, -0.0027590916d, -0.017594207d, -0.026804507d, -0.0014236979d, -0.022032745d, 0.0091236625d, -0.0042419364d, -0.00858384d, -0.0033905501d, -0.020739838d, 0.016821127d, 0.022539245d, 0.015381602d, 0.015141681d, 0.028817179d, -0.019726837d, -0.0051283115d, -0.011489551d, -0.013208984d, -0.0047017853d, -0.0072309524d, 0.01767418d, 0.0025658219d, -0.010323267d, 0.012609182d, -0.028097415d, 0.026871152d, -0.010276617d, 0.021912785d, 0.0022542577d, 0.005124979d, -0.0019710176d, 0.004518512d, -0.040360045d, 0.010969722d, -0.0031539614d, -0.020366628d, -0.025778178d, -0.0110030435d, -0.016221326d, 0.0036587953d, 0.016207997d, 0.003007343d, -0.0032555948d, 0.0044052163d, -0.022046074d, -0.0008822095d, -0.009363583d, 0.028230704d, -0.024538586d, 0.0029840174d, 0.0016044717d, -0.014181997d, 0.031349678d, -0.014381931d, -0.027750863d, 0.02613806d, 0.0004136138d, -0.005748107d, -0.01868718d, -0.0010138329d, 0.0054348772d, 0.010703143d, -0.003682121d, 0.0030856507d, -0.004275259d, -0.010403241d, 0.021113047d, -0.022685863d, -0.023032416d, 0.031429652d, 0.001792743d, -0.005644808d, -0.011842767d, -0.04078657d, -0.0026874484d, 0.06915057d, -0.00056939584d, -0.013995391d, 0.010703143d, -0.013728813d, -0.022939114d, -0.015261642d, -0.022485929d, 0.016807798d, 0.007964044d, 0.0144219175d, 0.016821127d, 0.0076241563d, 0.005461535d, -0.013248971d, 0.015301628d, 0.0085171955d, -0.004318578d, 0.011136333d, -0.0059047225d, -0.010249958d, -0.018207338d, 0.024645219d, 0.021752838d, 0.0007614159d, -0.013648839d, 0.01111634d, -0.010503208d, -0.0038487327d, -0.008203966d, -0.00397869d, 0.0029740208d, 0.008530525d, 0.005261601d, 0.01642126d, -0.0038753906d, -0.013222313d, 0.026537929d, 0.024671877d, -0.043505676d, 0.014195326d, 0.024778508d, 0.0056914594d, -0.025951454d, 0.017620865d, -0.0021359634d, 0.008643821d, 0.021299653d, 0.0041686273d, -0.009017031d, 0.04044002d, 0.024378639d, -0.027777521d, -0.014208655d, 0.0028623908d, 0.042119466d, 0.005801423d, -0.028124074d, -0.03129636d, 0.022139376d, -0.022179363d, -0.04067994d, 0.013688826d, 0.013328944d, 0.0046184794d, -0.02828402d, -0.0063412455d, -0.0046184794d, -0.011756129d, -0.010383247d, -0.0018543894d, -0.0018593877d, -0.00052024535d, 0.004815081d, 0.014781799d, 0.018007403d, 0.01306903d, -0.020433271d, 0.009043689d, 0.033189073d, -0.006844413d, -0.019766824d, -0.018767154d, 0.00533491d, -0.0024575242d, 0.018727167d, 0.0058080875d, -0.013835444d, 0.0040719924d, 0.004881726d, 0.012029372d, 0.005664801d, 0.03193615d, 0.0058047553d, 0.002695779d, 0.009290274d, 0.02361889d, 0.017834127d, 0.0049017193d, -0.0036388019d, 0.010776452d, -0.019793482d, 0.0067777685d, -0.014208655d, -0.024911797d, 0.002385881d, 0.0034988478d, 0.020899786d, -0.0025858153d, -0.011849431d, 0.033189073d, -0.021312982d, 0.024965113d, -0.014635181d, 0.014048708d, -0.0035921505d, -0.003347231d, 0.030869836d, -0.0017161017d, -0.0061346465d, 0.009203636d, -0.025165047d, 0.0068510775d, 0.021499587d, 0.013782129d, -0.0024475274d, -0.0051149824d, -0.024445284d, 0.006167969d, 0.0068844d, -0.00076183246d, 0.030150073d, -0.0055948244d, -0.011162991d, -0.02057989d, -0.009703471d, -0.020646535d, 0.008004031d, 0.0066378145d, -0.019900113d, -0.012169327d, -0.01439526d, 0.0044252095d, -0.004018677d, 0.014621852d, -0.025085073d, -0.013715484d, -0.017980747d, 0.0071043274d, 0.011456228d, -0.01010334d, -0.0035321703d, -0.03801415d, -0.012036037d, -0.0028990454d, -0.05419549d, -0.024058744d, -0.024272008d, 0.015221654d, 0.027964126d, 0.03182952d, -0.015354944d, 0.004855068d, 0.011522872d, 0.004771762d, 0.0027874154d, 0.023405626d, 0.0004242353d, -0.03132302d, 0.007057676d, 0.008763781d, -0.0027057757d, 0.023005757d, -0.0071176565d, -0.005238275d, 0.029110415d, -0.010989714d, 0.013728813d, -0.009630162d, -0.029137073d, -0.0049317093d, -0.0008630492d, -0.015248313d, 0.0043219104d, -0.0055681667d, -0.013175662d, 0.029723546d, 0.025098402d, 0.012849103d, -0.0009996708d, 0.03118973d, -0.0021709518d, 0.0260181d, -0.020526575d, 0.028097415d, -0.016141351d, 0.010509873d, -0.022965772d, 0.002865723d, 0.0020493253d, 0.0020509914d, -0.0041419696d, -0.00039695262d, 0.017287642d, 0.0038987163d, 0.014795128d, -0.014661839d, -0.008950386d, 0.004431874d, -0.009383577d, 0.0012604183d, -0.023019087d, 0.0029273694d, -0.033135757d, 0.009176978d, -0.011023037d, -0.002102641d, 0.02663123d, -0.03849399d, -0.0044152127d, 0.0004527676d, -0.0026924468d, 0.02828402d, 0.017727496d, 0.035135098d, 0.02728435d, -0.005348239d, -0.001467017d, -0.019766824d, 0.014715155d, 0.011982721d, 0.0045651635d, 0.023458943d, -0.0010046692d, -0.0031373003d, -0.0006972704d, 0.0019043729d, -0.018967088d, -0.024311995d, 0.0011546199d, 0.007977373d, -0.004755101d, -0.010016702d, -0.02780418d, -0.004688456d, 0.013022379d, -0.005484861d, 0.0017227661d, -0.015394931d, -0.028763862d, -0.026684547d, 0.0030589928d, -0.018513903d, 0.028363993d, 0.0044818576d, -0.009270281d, 0.038920518d, -0.016008062d, 0.0093902415d, 0.004815081d, -0.021059733d, 0.01451522d, -0.0051583014d, 0.023765508d, -0.017874114d, -0.016821127d, -0.012522544d, -0.0028390652d, 0.0040886537d, 0.020259995d, -0.031216389d, -0.014115352d, -0.009176978d, 0.010303274d, 0.020313311d, 0.0064112223d, -0.02235264d, -0.022872468d, 0.0052449396d, 0.0005723116d, 0.0037321046d, 0.016807798d, -0.018527232d, -0.009303603d, 0.0024858483d, -0.0012662497d, -0.007110992d, 0.011976057d, -0.007790768d, -0.042999174d, -0.006727785d, -0.011829439d, 0.007024354d, 0.005278262d, -0.017740825d, -0.0041519664d, 0.0085905045d, 0.027750863d, -0.038387362d, 0.024391968d, 0.00087721116d, 0.010509873d, -0.00038508154d, -0.006857742d, 0.0183273d, -0.0037054466d, 0.015461575d, 0.0017394272d, -0.0017944091d, 0.014181997d, -0.0052682655d, 0.009023695d, 0.00719763d, -0.013522214d, 0.0034422d, 0.014941746d, -0.0016711164d, -0.025298337d, -0.017634194d, 0.0058714002d, -0.005321581d, 0.017834127d, 0.0110630235d, -0.03369557d, 0.029190388d, -0.008943722d, 0.009363583d, -0.0034222065d, -0.026111402d, -0.007037683d, -0.006561173d, 0.02473852d, -0.007084334d, -0.010110005d, -0.008577175d, 0.0030439978d, -0.022712521d, 0.0054582027d, -0.0012620845d, -0.0011954397d, -0.015741484d, 0.0129557345d, -0.00042111133d, 0.00846388d, 0.008930393d, 0.016487904d, 0.010469886d, -0.007917393d, -0.011762793d, -0.0214596d, 0.000917198d, 0.021672864d, 0.010269952d, -0.007737452d, -0.010243294d, -0.0067244526d, -0.015488233d, -0.021552904d, 0.017127695d, 0.011109675d, 0.038067464d, 0.00871713d, -0.0025591573d, 0.021312982d, -0.006237946d, 0.034628596d, -0.0045251767d, 0.008357248d, 0.020686522d, 0.0010696478d, 0.0076708077d, 0.03772091d, -0.018700508d, -0.0020676525d, -0.008923728d, -0.023298996d, 0.018233996d, -0.010256623d, 0.0017860786d, 0.009796774d, -0.00897038d, -0.01269582d, -0.018527232d, 0.009190307d, -0.02372552d, -0.042119466d, 0.008097334d, -0.0066778013d, -0.021046404d, 0.0019593548d, 0.011083017d, -0.0016028056d, 0.012662497d, -0.000059095124d, 0.0071043274d, -0.014675168d, 0.024831824d, -0.053582355d, 0.038387362d, 0.0005698124d, 0.015954746d, 0.021552904d, 0.031589597d, -0.009230294d, -0.0006147976d, 0.002625802d, -0.011749465d, -0.034362018d, -0.0067844326d, -0.018793812d, 0.011442899d, -0.008743787d, 0.017474247d, -0.021619547d, 0.01831397d, -0.009037024d, -0.0057247817d, -0.02728435d, 0.010363255d, 0.034415334d, -0.024032086d, -0.0020126705d, -0.0045518344d, -0.019353628d, -0.018340627d, -0.03129636d, -0.0034038792d, -0.006321252d, -0.0016161345d, 0.033642255d, -0.000056075285d, -0.005005019d, 0.004571828d, -0.0024075406d, -0.00010215386d, 0.0098634185d, 0.1980148d, -0.003825407d, -0.025191706d, 0.035161756d, 0.005358236d, 0.025111731d, 0.023485601d, 0.0023342315d, -0.011882754d, 0.018287312d, -0.0068910643d, 0.003912045d, 0.009243623d, -0.001355387d, -0.028603915d, -0.012802451d, -0.030150073d, -0.014795128d, -0.028630573d, -0.0013487226d, 0.002667455d, 0.00985009d, -0.0033972147d, -0.021486258d, 0.009503538d, -0.017847456d, 0.013062365d, -0.014341944d, 0.005078328d, 0.025165047d, -0.015594865d, -0.025924796d, -0.0018177348d, 0.010996379d, -0.02993681d, 0.007324255d, 0.014475234d, -0.028577257d, 0.005494857d, 0.00011725306d, -0.013315615d, 0.015941417d, 0.009376912d, 0.0025158382d, 0.008743787d, 0.023832154d, -0.008084005d, -0.014195326d, -0.008823762d, 0.0033455652d, -0.032362677d, -0.021552904d, -0.0056081535d, 0.023298996d, -0.025444955d, 0.0097301295d, 0.009736794d, 0.015274971d, -0.0012937407d, -0.018087378d, -0.0039387033d, 0.008637156d, -0.011189649d, -0.00023846315d, -0.011582852d, 0.0066411467d, -0.018220667d, 0.0060846633d, 0.0376676d, -0.002709108d, 0.0072776037d, 0.0034188742d, -0.010249958d, -0.0007747449d, -0.00795738d, -0.022192692d, 0.03910712d, 0.032122757d, 0.023898797d, 0.0076241563d, -0.007397564d, -0.003655463d, 0.011442899d, -0.014115352d, -0.00505167d, -0.031163072d, 0.030336678d, -0.006857742d, -0.022259338d, 0.004048667d, 0.02072651d, 0.0030156737d, -0.0042119464d, 0.00041861215d, -0.005731446d, 0.011103011d, 0.013822115d, 0.021512916d, 0.009216965d, -0.006537847d, -0.027057758d, -0.04054665d, 0.010403241d, -0.0056281467d, -0.005701456d, -0.002709108d, -0.00745088d, -0.0024841821d, 0.009356919d, -0.022659205d, 0.004061996d, -0.013175662d, 0.017074378d, -0.006141311d, -0.014541878d, 0.02993681d, -0.00028448965d, -0.025271678d, 0.011689484d, -0.014528549d, 0.004398552d, -0.017274313d, 0.0045751603d, 0.012455898d, 0.004121976d, -0.025458284d, -0.006744446d, 0.011822774d, -0.015035049d, -0.03257594d, 0.014675168d, -0.0039187097d, 0.019726837d, -0.0047251107d, 0.0022825818d, 0.011829439d, 0.005391558d, -0.016781142d, -0.0058747325d, 0.010309938d, -0.013049036d, 0.01186276d, -0.0011246296d, 0.0062112883d, 0.0028190718d, -0.021739509d, 0.009883412d, -0.0073175905d, -0.012715813d, -0.017181009d, -0.016607866d, -0.042492677d, -0.0014478565d, -0.01794076d, 0.012302616d, -0.015194997d, -0.04433207d, -0.020606548d, 0.009696807d, 0.010303274d, -0.01694109d, -0.004018677d, 0.019353628d, -0.001991011d, 0.000058938927d, 0.010536531d, -0.17274313d, 0.010143327d, 0.014235313d, -0.024152048d, 0.025684876d, -0.0012504216d, 0.036601283d, -0.003698782d, 0.0007310093d, 0.004165295d, -0.0029157067d, 0.017101036d, -0.046891227d, -0.017460918d, 0.022965772d, 0.020233337d, -0.024072073d, 0.017220996d, 0.009370248d, 0.0010363255d, 0.0194336d, -0.019606877d, 0.01818068d, -0.020819811d, 0.007410893d, 0.0019326969d, 0.017887443d, 0.006651143d, 0.00067394477d, -0.011889419d, -0.025058415d, -0.008543854d, 0.021579562d, 0.0047484366d, 0.014062037d, 0.0075508473d, -0.009510202d, -0.009143656d, 0.0046817916d, 0.013982063d, -0.0027990784d, 0.011782787d, 0.014541878d, -0.015701497d, -0.029350337d, 0.021979429d, 0.01332228d, -0.026244693d, -0.0123492675d, -0.003895384d, 0.0071576433d, -0.035454992d, -0.00046984528d, 0.0033522295d, 0.039347045d, 0.0005119148d, 0.00476843d, -0.012995721d, 0.0024042083d, -0.006931051d, -0.014461905d, -0.0127558d, 0.0034555288d, -0.0074842023d, -0.030256703d, -0.007057676d, -0.00807734d, 0.007804097d, -0.006957709d, 0.017181009d, -0.034575284d, -0.008603834d, -0.005008351d, -0.015834786d, 0.02943031d, 0.016861115d, -0.0050849924d, 0.014235313d, 0.0051449724d, 0.0025924798d, -0.0025741523d, 0.04289254d, -0.002104307d, 0.012969063d, -0.008310596d, 0.00423194d, 0.0074975314d, 0.0018810473d, -0.014248641d, -0.024725191d, 0.0151016945d, -0.017527562d, 0.0018727167d, 0.0002830318d, 0.015168339d, 0.0144219175d, -0.004048667d, -0.004358565d, 0.011836103d, -0.010343261d, -0.005911387d, 0.0022825818d, 0.0073175905d, 0.00403867d, 0.013188991d, 0.03334902d, 0.006111321d, 0.008597169d, 0.030123414d, -0.015474904d, 0.0017877447d, -0.024551915d, 0.013155668d, 0.023525586d, -0.0255116d, 0.017220996d, 0.004358565d, -0.00934359d, 0.0099967085d, 0.011162991d, 0.03092315d, -0.021046404d, -0.015514892d, 0.0011946067d, -0.01816735d, 0.010876419d, -0.10124666d, -0.03550831d, 0.0056348112d, 0.013942076d, 0.005951374d, 0.020419942d, -0.006857742d, -0.020873128d, -0.021259667d, 0.0137554705d, 0.0057880944d, -0.029163731d, -0.018767154d, -0.021392956d, 0.030896494d, -0.005494857d, -0.0027307675d, -0.006801094d, -0.014821786d, 0.021392956d, -0.0018110704d, -0.0018843795d, -0.012362596d, -0.0072176233d, -0.017194338d, -0.018713837d, -0.024272008d, 0.03801415d, 0.00015880188d, 0.0044951867d, -0.028630573d, -0.0014070367d, -0.00916365d, -0.026537929d, -0.009576847d, -0.013995391d, -0.0077107945d, 0.0050016865d, 0.00578143d, -0.04467862d, 0.008363913d, 0.010136662d, -0.0006268769d, -0.006591163d, 0.015341615d, -0.027377652d, -0.00093136d, 0.029243704d, -0.020886457d, -0.01041657d, -0.02424535d, 0.005291591d, -0.02980352d, -0.009190307d, 0.019460259d, -0.0041286405d, 0.004801752d, 0.0011787785d, -0.001257086d, -0.011216307d, -0.013395589d, 0.00088137644d, -0.0051616337d, 0.03876057d, -0.0033455652d, 0.00075850025d, -0.006951045d, -0.0062112883d, 0.018140694d, -0.006351242d, -0.008263946d, 0.018154023d, -0.012189319d, 0.0075508473d, -0.044358727d, -0.0040153447d, 0.0093302615d, -0.010636497d, 0.032789204d, -0.005264933d, -0.014235313d, -0.018393943d, 0.007297597d, -0.016114693d, 0.015021721d, 0.020033404d, 0.0137688d, 0.0011046362d, 0.010616505d, -0.0039453674d, 0.012109346d, 0.021099718d, -0.0072842683d, -0.019153694d, -0.003768759d, 0.039320387d, -0.006747778d, -0.0016852784d, 0.018154023d, 0.0010963057d, -0.015035049d, -0.021033075d, -0.04345236d, 0.017287642d, 0.016341286d, -0.008610498d, 0.00236922d, 0.009290274d, 0.028950468d, -0.014475234d, -0.0035654926d, 0.015434918d, -0.03372223d, 0.004501851d, -0.012929076d, -0.008483873d, -0.0044685286d, -0.0102233d, 0.01615468d, 0.0022792495d, 0.010876419d, -0.0059647025d, 0.01895376d, -0.0069976957d, -0.0042952523d, 0.017207667d, -0.00036133936d, 0.0085905045d, 0.008084005d, 0.03129636d, -0.016994404d, -0.014915089d, 0.020100048d, -0.012009379d, -0.006684466d, 0.01306903d, 0.00015765642d, -0.00530492d, 0.0005277429d, 0.015421589d, 0.015528221d, 0.032202728d, -0.003485519d, -0.0014286962d, 0.033908837d, 0.001367883d, 0.010509873d, 0.025271678d, -0.020993087d, 0.019846799d, 0.006897729d, -0.010216636d, -0.00725761d, 0.01818068d, -0.028443968d, -0.011242964d, -0.014435247d, -0.013688826d, 0.006101324d, -0.0022509254d, 0.013848773d, -0.0019077052d, 0.017181009d, 0.03422873d, 0.005324913d, -0.0035188415d, 0.014128681d, -0.004898387d, 0.005038341d, 0.0012320944d, -0.005561502d, -0.017847456d, 0.0008538855d, -0.0047884234d, 0.011849431d, 0.015421589d, -0.013942076d, 0.0029790192d, -0.013702155d, 0.0001199605d, -0.024431955d, 0.019926772d, 0.022179363d, -0.016487904d, -0.03964028d, 0.0050849924d, 0.017487574d, 0.022792496d, 0.0012504216d, 0.004048667d, -0.00997005d, 0.0076041627d, -0.014328616d, -0.020259995d, 0.0005598157d, -0.010469886d, 0.0016852784d, 0.01716768d, -0.008990373d, -0.001987679d, 0.026417969d, 0.023792166d, 0.0046917885d, -0.0071909656d, -0.00032051947d, -0.023259008d, -0.009170313d, 0.02071318d, -0.03156294d, -0.030869836d, -0.006324584d, 0.013795458d, -0.00047151142d, 0.016874444d, 0.00947688d, 0.00985009d, -0.029883493d, 0.024205362d, -0.013522214d, -0.015075036d, -0.030603256d, 0.029270362d, 0.010503208d, 0.021539574d, 0.01743426d, -0.023898797d, 0.022019416d, -0.0068777353d, 0.027857494d, -0.021259667d, 0.0025758184d, 0.006197959d, 0.006447877d, -0.00025200035d, -0.004941706d, -0.021246338d, -0.005504854d, -0.008390571d, -0.0097301295d, 0.027244363d, -0.04446536d, 0.05216949d, 0.010243294d, -0.016008062d, 0.0122493d, -0.0199401d, 0.009077012d, 0.019753495d, 0.006431216d, -0.037960835d, -0.027377652d, 0.016381273d, -0.0038620618d, 0.022512587d, -0.010996379d, -0.0015211658d, -0.0102233d, 0.007071005d, 0.008230623d, -0.009490209d, -0.010083347d, 0.024431955d, 0.002427534d, 0.02828402d, 0.0035721571d, -0.022192692d, -0.011882754d, 0.010056688d, 0.0011904413d, -0.01426197d, -0.017500903d, -0.00010985966d, 0.005591492d, -0.0077707744d, -0.012049366d, 0.011869425d, 0.00858384d, -0.024698535d, -0.030283362d, 0.020140035d, 0.011949399d, -0.013968734d, 0.042732596d, -0.011649498d, -0.011982721d, -0.016967745d, -0.0060913274d, -0.007130985d, -0.013109017d, -0.009710136d)); 26 String indexName = "vector_index"; 27 FieldSearchPath fieldSearchPath = fieldPath("plot_embedding"); 28 int numCandidates = 150; 29 int limit = 10; 30 31 // define pipeline 32 List<Bson> pipeline = asList( 33 vectorSearch( 34 fieldSearchPath, 35 queryVector, 36 indexName, 37 numCandidates, 38 limit), 39 project( 40 fields(exclude("_id"), include("title"), include("plot"), 41 metaVectorSearchScore("score")))); 42 43 // run query and print results 44 collection.aggregate(pipeline) 45 .forEach(doc -> System.out.println(doc.toJson())); 46 } 47 } 48 }
1 {"plot": "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title": "Thrill Seekers", "score": 0.7892671227455139} 2 {"plot": "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title": "About Time", "score": 0.7843604683876038} 3 {"plot": "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title": "The Time Machine", "score": 0.7801066637039185} 4 {"plot": "After using his mother's newly built time machine, Dolf gets stuck involuntary in the year 1212. He ends up in a children's crusade where he confronts his new friends with modern techniques...", "title": "Crusade in Jeans", "vectorSearchScore": 0.7789170742034912} 5 {"plot": "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title": "Timecop", "score": 0.7771612405776978} 6 {"plot": "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title": "A.P.E.X.", "vectorSearchScore": 0.7730885744094849} 7 {"plot": "Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.", "title": "Men in Black 3", "score": 0.7712380886077881} 8 {"plot": "Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.", "title": "Tomorrowland", "score": 0.7669923901557922} 9 {"plot": "With the help of his uncle, a man travels to the future to try and bring his girlfriend back to life.", "title": "Love Story 2050", "vectorSearchScore": 0.7649372816085815} 10 {"plot": "A dimension-traveling wizard gets stuck in the 21st century because cell-phone radiation interferes with his magic. With his home world on the brink of war, he seeks help from a jaded ...", "title": "The Portal", "score": 0.7640786170959473}
The following query filters the documents for movies released between
January 01, 1955
and January 01, 1975
before performing the
semantic search against the sample vector data. It uses the
$and
operator to perform a logical AND
operation of the
specified dates. It then searches the plot_embedding
field in the
filtered documents for 150
nearest neighbors using the vector
embeddings for the string kids adventure, and returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include onlyplot
,title
, andyear
fields in the results.Add a field named
score
that shows the vector search score of the documents in the results.
1 import static com.mongodb.client.model.Aggregates.*; 2 import static com.mongodb.client.model.Projections.*; 3 import static com.mongodb.client.model.search.SearchPath.fieldPath; 4 import static com.mongodb.client.model.search.VectorSearchOptions.vectorSearchOptions; 5 import static java.util.Arrays.asList; 6 7 import com.mongodb.client.MongoClient; 8 import com.mongodb.client.MongoClients; 9 import com.mongodb.client.MongoCollection; 10 import com.mongodb.client.MongoDatabase; 11 import com.mongodb.client.model.*; 12 import com.mongodb.client.model.search.VectorSearchOptions; 13 import java.util.List; 14 import com.mongodb.client.model.search.FieldSearchPath; 15 import org.bson.Document; 16 import org.bson.conversions.Bson; 17 18 public class FilterQuery { 19 public static void main( String[] args ) { 20 // specify connection 21 String uri = "<connection-string>"; 22 23 // establish connection and set namespace 24 try (MongoClient mongoClient = MongoClients.create(uri)) { 25 MongoDatabase database = mongoClient.getDatabase("sample_mflix"); 26 MongoCollection<Document> collection = database.getCollection("embedded_movies"); 27 28 // define $vectorSearch query options 29 List<Double> queryVector = (asList(0.02421053,-0.022372592,-0.006231137,-0.02168502,-0.020375984,0.037552103,-0.010505334,-0.027026938,0.0070674648,-0.020032197,0.01783725,0.016303431,0.014584498,-0.018736385,0.009031017,-0.0045981496,0.02750295,-0.028322749,0.010624337,-0.024236975,-0.0048659067,0.015153068,-0.000490888,-0.022161031,-0.0024560927,-0.007411252,0.009745035,-0.01886861,0.02112967,-0.011939983,0.015153068,0.0025800543,0.017824028,-0.02410475,-0.016633997,-0.0018214093,-0.008323609,-0.009222744,0.009388026,-0.0028296304,0.0017536436,0.0065517845,-0.011635863,-0.028454976,-0.018934723,0.012951509,-0.0032015154,-0.005880739,-0.03115238,0.012951509,0.0057749585,0.009202911,-0.0069352393,0.00205611,0.0063732797,0.0039700773,-0.007100521,-0.0077087595,0.011596196,-0.010207825,-0.007100521,-0.0051006074,-0.01670011,0.012773004,-0.035304267,-0.0074971984,0.0025800543,-0.006118745,0.030253245,-0.0010751605,0.039456155,0.007821151,-0.0017189344,-0.0010801188,0.0062575825,-0.011490415,-0.022637043,0.004743598,-0.012601111,0.0197413,-0.0015255542,-0.025942687,-0.03284487,0.020389207,0.009797926,0.0141217075,-0.0015172901,0.025982354,-0.011589585,-0.001138794,0.0006131968,0.016832335,0.017916586,0.014412603,-0.0027155858,0.011854036,-0.02169824,0.02112967,-0.020680103,-0.007391418,-0.012872174,0.021473458,0.0047766543,-0.0048394613,-0.024395647,0.0065418677,0.009797926,-0.00449898,0.041836217,0.0023833686,-0.021737909,0.0136721395,0.014148152,-0.028772317,-0.027899627,-0.015695194,-0.012521776,0.02205525,-0.01927851,-0.022068473,0.020971,0.02317917,0.030544141,-0.011827591,0.0075170323,0.023086611,-0.02164535,-0.01732157,0.007510421,-0.027635176,0.016263764,-0.0008801275,0.033109322,-0.014505162,-0.029909458,0.036679417,0.0074971984,0.0059137954,-0.031178825,-0.012634167,0.008416167,0.030491251,-0.016832335,-0.009507029,0.010016099,0.009778093,0.007840985,0.010928456,-0.009685534,-0.027661622,0.024752656,-0.024871659,0.01516629,0.002778393,0.0059501575,0.022042029,0.0005441915,0.0076889256,-0.009883873,-0.019966085,0.008508725,0.0098045375,0.0091169635,-0.02750295,0.012501942,0.03480181,0.021751132,0.020746216,0.003546955,-0.014690278,0.010445832,0.008469057,-0.00007535833,0.0059600743,-0.013526691,0.029539226,-0.011126795,0.025400562,-0.025466675,-0.0046080663,-0.013923368,-0.009011183,0.019318178,0.019053727,-0.012085431,-0.0074707535,0.0013024234,0.0076624807,0.0060460214,-0.0023007276,0.017757915,0.031258162,0.0008768218,-0.003695709,-0.6981518,-0.012058986,0.008931847,-0.02914255,0.00833022,0.028349195,0.013857256,0.0029668147,-0.008164939,-0.001494977,-0.0011197866,0.0104855,0.014610942,-0.0066608707,0.000643774,0.0020676798,0.008607894,-0.023787407,0.020494986,0.015443964,-0.019833859,0.012905231,0.013387854,-0.020918109,0.0035800114,0.026775708,0.005920407,-0.018233927,-0.008759954,0.0005437783,-0.022081695,0.0071996907,-0.002963509,0.004092386,0.057967756,-0.015285294,-0.008978127,0.027740957,0.015853863,0.047178138,-0.018366152,-0.0064889775,0.029777233,0.0141217075,0.007847597,0.02200236,0.031125935,0.010611114,-0.00663112,-0.005940241,0.017215788,-0.019992528,-0.01644888,-0.013447356,0.001490845,0.007893875,0.016276987,-0.0062939445,0.00032333322,0.0020230536,-0.025360893,0.028587202,-0.009645866,0.01459772,-0.012376328,0.03202507,-0.006059244,0.010888788,0.014518384,-0.034405135,0.023364285,0.018895056,-0.009361581,-0.0011255714,0.00663112,0.016885225,0.01609187,-0.006750123,-0.035304267,0.0022660184,0.027714511,0.01680589,-0.03686453,-0.008045935,0.052943178,-0.0091169635,-0.0066840104,0.018405821,0.00027374856,0.0005235312,0.0138969235,0.018075256,0.0005850988,-0.0074971984,0.0011255714,-0.011054071,-0.0022048638,0.0043931995,0.021142893,-0.02472621,-0.007232747,0.0014858865,-0.00062228733,-0.017903363,-0.0013495288,-0.0001454483,0.0027370725,0.0060129645,0.0364943,-0.04601455,-0.008713675,-0.017215788,-0.017784359,-0.007100521,-0.014610942,-0.027978962,0.0046179835,-0.010267328,0.036785197,-0.019542962,0.028719427,0.004343615,0.0067765685,-0.018075256,-0.004462618,0.010121879,-0.0024957606,-0.00883929,0.0017007533,-0.011371412,-0.007788095,0.002418078,-0.01053839,-0.018458711,-0.0048328503,0.0035072872,0.0043568374,-0.006389808,0.027635176,-0.002768476,-0.033479553,-0.0069749067,-0.00096276856,-0.0034048124,0.012773004,-0.01979419,-0.003675875,-0.011655698,-0.026709596,-0.0009206216,-0.009295468,0.011391246,0.0050510224,0.0027486421,0.0024246892,-0.01264739,0.004687402,-0.0058377655,0.0117945345,-0.009388026,0.010545001,0.020481765,-0.000089768866,-0.022425482,-0.013487023,-0.008316998,-0.019503294,0.025942687,0.0076889256,-0.03355889,-0.0071071326,-0.019106617,-0.015430742,0.021724686,0.0019652047,0.011113572,-0.019410737,-0.023615515,0.000523118,0.019027282,-0.015853863,-0.011887092,-0.021804022,-0.013473801,-0.0049518533,-0.00071773777,-0.003194904,0.046411227,-0.0108689545,0.04003795,-0.0026626955,0.03146972,-0.005804709,-0.013645695,0.0046973187,-0.010148324,0.02292794,0.0310466,0.018709939,0.020005751,0.028534312,-0.02134123,0.044031166,-0.00021548661,0.018458711,-0.038795028,-0.00930208,-0.013738252,0.029486336,-0.0019503294,0.008812845,-0.02755584,0.004852684,-0.013301908,0.000006940559,0.017453795,-0.005249361,0.0069352393,-0.023205614,-0.02040243,-0.0060493266,-0.017110009,0.011417692,0.006882349,-0.019556185,0.015893532,-0.0028874793,-0.0023387424,-0.0034610082,-0.009427694,-0.009705368,0.002194947,-0.008191383,0.021804022,-0.016250541,0.0053320024,0.037393436,-0.014174597,0.031073045,0.004108914,0.010029321,0.018538047,0.007675703,-0.012568055,-0.0080525465,0.0013487024,0.03234241,-0.009983042,-0.014782836,0.0069418503,-0.014346491,-0.0009875608,-0.024924548,0.035145596,0.009592976,-0.010902011,0.0047568204,0.006194775,0.011344967,0.028349195,0.0062410543,-0.0027172386,0.011080516,0.012303604,0.012263936,-0.009844205,-0.004766737,-0.0062079974,-0.005748513,-0.01979419,-0.006036104,-0.018630605,-0.00050204457,-0.013830811,0.0015338184,-0.00418825,-0.020799106,-0.016792666,-0.0034015067,0.034352243,0.00915002,-0.019767746,0.016462103,0.014346491,-0.009672312,-0.032606862,-0.010035932,-0.0035238154,-0.018934723,0.012204434,-0.015946422,0.022597376,-0.00081194856,0.002740378,0.0088921795,0.0056361216,0.011549917,-0.0088789575,0.008720286,0.007424474,-0.0022263506,0.0020131366,-0.023165947,-0.037181873,0.014756391,0.011424302,-0.0057385964,-0.014690278,-0.018709939,-0.005536952,-0.0064228643,0.00418825,-0.023787407,0.012845729,-0.009487196,-0.011754867,-0.008746731,-0.013844033,0.026643483,0.009070684,-0.016554661,-0.024078304,-0.013553137,0.011146628,0.11075226,-0.007854208,0.0024098137,0.005685706,0.0032081266,-0.00603941,-0.022161031,0.0004933672,0.0014486981,-0.001134662,0.007345139,0.008237663,-0.0019057032,0.007120355,-0.009864039,0.03115238,-0.00041051954,-0.00344448,-0.013063901,-0.020997444,0.013222572,-0.002824672,0.018366152,0.025889797,0.007523644,-0.019648742,-0.007391418,0.02168502,-0.0019255371,-0.018524824,-0.00021156116,-0.004826239,-0.001088383,-0.0071468004,0.0000106013,-0.002963509,0.015430742,0.029036768,0.035806727,-0.016924892,0.039271038,0.02503033,0.019648742,-0.02636581,0.0035634832,-0.00044254295,-0.016435657,0.012792839,0.008270719,-0.03469603,0.052599393,0.008270719,-0.0052824174,-0.0059534633,0.023668405,0.011159851,-0.018128147,-0.0064856717,0.009606198,-0.015258849,0.00291723,-0.028851653,0.019133061,-0.012323437,-0.01516629,-0.027846737,-0.019820636,0.0024974134,-0.01377792,-0.00067063235,-0.022703156,-0.009156631,-0.012303604,-0.023311395,0.006174941,0.0073980293,0.012343272,-0.015721638,-0.00033097752,0.019146284,0.011761478,-0.019542962,-0.0057452074,-0.0076823146,-0.002343701,0.007840985,0.014941507,0.007847597,-0.004029579,0.008812845,0.029168995,0.01876283,0.01125902,-0.010611114,0.00021734604,-0.0037948783,-0.0016445575,0.028587202,0.015086955,0.0035899284,0.0009900401,-0.019622298,-0.00704102,-0.0062410543,0.0027106274,0.009652478,-0.01573486,0.0152985165,0.0046774847,-0.02595591,0.0115565285,-0.021989137,0.010961512,-0.011179685,0.011781312,-0.00055782724,-0.0033238241,-0.0012619293,0.02066688,-0.014372936,0.006399725,-0.022332925,0.011014403,0.01927851,-0.008733509,0.003798184,0.017744692,-0.036732305,0.0077087595,0.005454311,-0.0038676024,0.01696456,-0.00037973575,0.0058212373,-0.030517697,-0.012006096,0.012482109,0.015946422,0.0031899456,0.001283416,-0.0055898423,0.01737446,0.03633563,0.015642302,-0.002953592,-0.02446176,-0.011364801,-0.023033721,-0.003798184,0.03726121,-0.021513125,0.014505162,-0.008971515,-0.0023007276,0.0009231008,-0.03916526,-0.023364285,0.008145104,0.020997444,0.025889797,0.0302268,-0.02107678,0.03720832,-0.009936763,0.013361409,-0.00080492406,-0.015972868,-0.0035172042,-0.041968442,0.012369717,0.020389207,0.011530083,0.0016420782,-0.026947603,0.010465666,0.009983042,0.011549917,-0.013923368,-0.0075699226,-0.012442441,0.0031635005,-0.0003237464,-0.009196299,0.007920321,-0.003556872,0.0043105586,0.036520746,0.0029155773,-0.0025073302,-0.016224096,0.0094541395,-0.016409213,0.01192676,0.0008702105,0.014796059,0.002148668,-0.013414299,-0.026154248,-0.02235937,0.011801146,0.012442441,-0.0016685233,0.008898791,0.0063931136,-0.01094829,0.013963036,0.002611458,-0.015880309,0.01789014,-0.0050378,-0.0035800114,-0.016885225,0.0073120827,-0.040117282,0.005748513,0.0027536007,-0.022676712,0.008674008,-0.024699764,0.0045783157,-0.030676367,0.0008602936,0.038742136,0.010551613,0.020812329,0.0017354626,0.011278854,-0.0068559037,-0.016686887,-0.007424474,0.0022759351,0.014452271,0.0141217075,0.0020296648,-0.0016784403,-0.017810805,-0.009526864,-0.015906755,-0.012092043,0.0143597135,-0.009090519,0.01352008,-0.012620945,-0.008270719,-0.013288685,0.027978962,-0.0049882154,-0.0044791466,-0.008726898,-0.015946422,-0.02153957,0.012938287,-0.016753,0.022531264,0.015933199,-0.013361409,0.03834546,-0.001832979,-0.008773177,-0.012111876,-0.02524189,0.024792323,0.009758258,0.029327665,0.01141108,0.01022766,-0.016726553,0.008409556,0.011424302,0.023192393,0.0021354454,-0.01346719,-0.016435657,0.0051072184,-0.0037485992,-0.015338183,-0.009374804,-0.02251804,-0.026815377,-0.022703156,0.01582742,0.016951337,-0.014491939,-0.011523472,-0.018154591,0.0061418847,-0.00039378472,-0.009599588,0.00061898166,-0.026088135,-0.010809453,-0.012680447,0.0011892051,0.00817155,-0.011060682,-0.007834374,-0.0015015884,0.018974392,-0.026379032,0.01794303,-0.029063214,0.005731985,-0.015721638,0.013202738,0.018855387,-0.017043896,0.021883357,-0.00976487,-0.0063501406,0.0006817889,-0.021010667,-0.0034411745,-0.019701632,-0.015999312,-0.0065418677,0.0036130678,-0.015615858,-0.017519908,-0.035330713,0.029486336,0.0007094736,-0.015351406,-0.00010252659,-0.0019618992,0.02565179,0.0023751045,0.024382424,-0.007807929,-0.016157983,-0.008012879,-0.0076823146,0.020256981,-0.0023784102,-0.01125902,-0.017229011,-0.009163243,-0.0073980293,0.018802498,0.0007470753,0.004786571,0.038133897,0.022782492,0.0136721395,0.0048394613,-0.00033986144,0.0070608538,0.005771653,-0.026167471,-0.021394122,-0.0039237984,0.01922562,0.03868925,0.00899796,-0.021658573,-0.010809453,-0.010604503,-0.011966428,0.0051733316,0.003074248,0.017757915,0.051620923,0.0036593468,-0.016673664,0.013024233,0.004826239,0.02750295,-0.00817155,-0.012865563,0.013037456,0.01758602,-0.0006045195,0.010187992,-0.03263331,-0.015814196,0.029274775,0.0018957863,-0.009672312,0.0011966428,-0.015748084,-0.0054972842,-0.041386653,0.012250713,0.007530255,0.0047204583,0.018286817,-0.02134123,0.0033915897,-0.007391418,-0.0035304269,-0.0032180436,-0.0002681703,-0.009361581,-0.013249017,0.02036276,-0.010749951,-0.02107678,-0.017242234,-0.01644888,0.02483199,-0.0060823835,0.0042576683,0.020071864,0.014372936,-0.013963036,-0.008350055,0.005474145,-0.0029321054,-0.029512782,-0.023046944,-0.017718246,0.0016106745,-0.021618906,-0.011490415,-0.009209521,0.009282245,0.01459772,0.024567539,-0.0021073474,0.02168502,0.0021040419,-0.025770793,0.0014296906,0.0042279176,-0.009553309,-0.0041254424,-0.012396161,0.0018395904,-0.016753,-0.0076889256,-0.0010991263,-0.022782492,0.004224612,0.014518384,0.015100177,-0.01315646,0.0036362074,0.19643453,-0.006902183,-0.01223088,0.0163431,-0.0065352563,0.018723162,0.0247791,-0.0050807735,-0.0047832653,-0.009196299,-0.014928284,0.027529396,0.0019933027,0.0026180693,0.0016205915,-0.01639599,-0.02153957,-0.017202567,-0.024131194,-0.03316221,-0.00085698796,-0.0063600573,-0.03181351,-0.009037628,0.0032907678,-0.0050378,-0.0010346663,-0.01835293,0.01361925,0.026088135,0.0005751819,-0.016819112,-0.009434305,0.0023354369,-0.020997444,-0.0067402064,0.008310387,0.0040626354,0.0040890803,0.030306136,-0.015959645,0.021037113,-0.0009916929,0.0070872987,-0.01161603,0.017096786,-0.001370189,-0.0042080837,0.0008140146,0.014108485,-0.02606169,-0.010472277,0.021261897,0.019966085,-0.011735033,-0.010908622,0.0016586065,0.029697897,-0.01830004,-0.011034236,-0.0038246291,0.031787064,-0.0079401545,0.0075500887,-0.009844205,0.022161031,-0.0044097276,0.0059600743,0.011959816,-0.019371068,0.0037915725,-0.015020842,-0.010968124,-0.0062741106,-0.00012179228,-0.027053382,0.03377045,0.005725374,0.0026891406,-0.0011602807,-0.00403619,-0.0076889256,0.0040791635,-0.0040989975,-0.018895056,-0.0197413,0.014756391,0.0057914867,-0.012296992,-0.017757915,0.008422779,-0.020137977,0.003537038,-0.0011040848,0.0061286623,0.031734172,-0.011748255,0.03207796,0.008204606,-0.0043270867,-0.02652448,-0.03501337,0.0050609396,0.015615858,-0.027476504,0.0026660012,0.00057104987,0.022861827,-0.012098653,-0.0024461758,0.01022766,-0.008350055,0.0114441365,0.0022081695,-0.0044130334,0.018009143,-0.0013867173,-0.016620774,-0.0060460214,-0.01459772,0.008164939,-0.013249017,0.005748513,0.005232833,-0.024950994,-0.011490415,-0.013480413,0.021552794,0.011285465,-0.03604473,0.0041915555,-0.0052096937,0.013037456,-0.012449052,-0.013037456,0.01639599,0.0051997765,-0.002267671,0.015047288,0.018643826,0.013976259,0.0052394443,0.0059534633,0.010016099,-0.0016528215,-0.03670586,0.023483288,0.008250885,-0.0051997765,-0.012607723,-0.019133061,-0.005798098,-0.012991177,-0.001120613,0.015272071,-0.03279198,-0.040646188,-0.014994397,-0.009031017,0.014108485,-0.011424302,0.021420566,0.0053353077,0.0052361386,-0.012607723,-0.0076823146,-0.17136453,-0.0011024319,0.011351578,-0.0062278314,0.008700453,0.0017106703,0.011992873,0.0048758234,-0.004568399,-0.0052460553,0.02729139,-0.013407689,-0.041809775,0.0023552708,0.025612123,0.031337496,-0.008925236,0.017004227,0.013989481,0.005252667,0.02344362,0.023879966,-0.0006917058,0.013949813,0.0005198124,0.0051072184,0.0040791635,0.0046576513,-0.012574666,-0.013698584,-0.012654002,-0.00344448,-0.006862515,0.012944899,0.023324618,0.004743598,-0.029724343,0.006307167,0.0016453839,0.0093549695,-0.008469057,0.035648055,0.01454483,-0.0115697505,0.011344967,0.015496855,-0.013738252,-0.0026610426,-0.005923712,-0.007953377,0.01609187,-0.02698727,0.011483804,-0.014796059,0.024408868,0.009778093,-0.0014437396,0.007001352,0.022068473,-0.011701977,-0.00007365386,-0.023377508,0.012964732,-0.010445832,-0.018114924,-0.04009084,-0.0056427326,0.0071269665,-0.03300354,0.028666537,-0.025850128,-0.017440572,0.007966599,-0.026484812,0.012409384,-0.0022032112,-0.009778093,-0.005798098,-0.015430742,-0.0028775623,-0.011629253,0.035304267,-0.03295065,0.019384291,-0.009513641,0.017387683,-0.019873526,-0.011113572,-0.012052375,-0.010531778,0.010459054,-0.034458023,-0.01876283,-0.00026589766,0.008217828,0.025202222,0.0009792967,-0.005712151,0.005150192,-0.01794303,-0.0048956573,-0.010895399,-0.007345139,-0.005725374,0.036917422,-0.009447528,0.042603128,0.017969476,0.03094082,-0.0061617186,0.01459772,0.0040031336,0.004340309,0.01979419,-0.0055799256,0.020349538,-0.019040504,-0.019648742,0.019780967,-0.0012842424,0.03839835,-0.0005590669,-0.023165947,-0.011067293,0.014015927,0.012303604,-0.10461699,-0.009315303,0.00067393796,0.021195784,-0.017506685,0.009427694,0.0045055915,0.00096194213,0.015919978,0.016435657,-0.014095262,0.0028676454,-0.004730375,-0.0136721395,0.010306995,-0.0073186937,-0.013401077,-0.0090045715,-0.019344624,0.009242578,-0.016686887,0.0007702148,0.012528387,-0.012025929,-0.022689935,-0.009976431,-0.032236632,0.02750295,0.004158499,0.01855127,0.002371799,-0.0053320024,0.007715371,-0.03252753,-0.013500246,0.011973039,-0.008469057,-0.0022924636,0.0213809,-0.04842106,0.018895056,0.0015858823,0.007576534,-0.024964217,0.014994397,0.0020412346,-0.005249361,0.0014792753,0.009348359,-0.03638852,-0.028402084,-0.01084251,-0.019979307,-0.0035304269,0.0036064566,-0.014994397,0.017652133,0.01305729,0.007907098,0.006667482,0.0028676454,-0.020005751,-0.012991177,0.03001524,-0.00046609566,0.015615858,-0.02935411,-0.0009925193,0.033796895,-0.019040504,-0.014901839,0.009533474,-0.010121879,0.026458368,-0.038054563,0.009956597,-0.0030048296,-0.0019519823,0.016872002,-0.001142926,-0.014941507,-0.02930122,0.004611372,-0.029512782,0.030887928,-0.0018015754,0.010624337,-0.0044791466,-0.007993045,-0.0056790947,0.0019602464,0.011173073,0.0023222142,-0.00022499033,0.0024511344,0.015443964,0.018987615,-0.02349651,-0.008740121,0.00029730127,-0.004750209,-0.017969476,-0.06442037,0.006816236,0.0019833858,0.0063038613,-0.0054675336,-0.01161603,0.032818425,-0.030094575,0.009685534,-0.0012520123,-0.0013090346,0.0085285595,0.015959645,-0.0006574098,-0.00688896,-0.019133061,-0.0008057505,0.009672312,0.019913195,0.008145104,-0.012290381,0.0016139803,0.026405476,0.014875393,-0.002168502,0.012792839,-0.011840814,0.003464314,0.0069682957,-0.0073781954,0.018842166,-0.03165484,-0.017242234,0.006789791,-0.009130186,-0.012263936,-0.015258849,0.0036692638,0.008865735,0.0272385,-0.004009745,-0.017612467,0.022584153,-0.023760963,0.004231223,0.004287419,-0.020891665,0.022425482,0.007986434,-0.0030345803,0.010459054,0.013844033,0.012283769,-0.027899627,-0.006250971,-0.023430398,0.0122573245,-0.004128748,0.013830811,-0.016766222,0.022861827,-0.011192908,0.03665297,-0.00212057,-0.009031017,-0.024170863,-0.0010230965,-0.0064393925,0.014015927,-0.005956769,0.000146378,-0.008436001,0.010604503,0.013169682,-0.00516672,0.0012321784,-0.022332925,-0.0022643656,-0.03993217,0.02050821,0.01577453,-0.0043667546,-0.022372592,-0.001152843,0.010002876,0.0036262905,-0.017876917,0.006406336,-0.009401249,0.019569406,-0.03033258,-0.01269367,0.0020412346,0.009989654,-0.0014627471,0.04101642,0.0011189602,-0.023046944,0.0013230836,0.024250198,0.01207882,-0.0062377485,-0.010452444,-0.020825552,0.006693927,-0.005305557,-0.018339708,-0.041307315,-0.012296992,0.0070542423,0.0019371068,0.0117945345,-0.020032197,0.017797582,-0.015443964,0.00537167,-0.00015474542,-0.0117747,-0.011140017,0.017334793,0.016250541,0.006019576,0.017612467,-0.017982699,0.010366497,0.0029949127,0.015086955,-0.000027813887,-0.008660785,-0.008713675,-0.0050873845,-0.0117945345,-0.016118316,-0.0022015583,0.006518728,-0.0047766543,0.0055501745,0.039747052,-0.034061346,0.049425974,0.0023883271,-0.0035601775,0.00863434,-0.003897353,0.016237319,0.006436087,-0.00037828952,-0.017797582,-0.019450404,0.0009809496,0.0036461244,0.013176293,0.0036461244,-0.01094829,-0.018260373,0.00035246418,0.012885396,-0.006796402,-0.015972868,0.027899627,-0.0077021485,0.027608732,0.01696456,-0.0014486981,-0.017969476,0.015642302,-0.00477996,-0.0048890463,-0.020058641,0.008323609,0.013017623,-0.01886861,-0.008204606,0.016303431,-0.010029321,-0.001018138,-0.0332151,0.010525168,0.032871313,0.011549917,0.010928456,-0.014253933,-0.011384634,0.00894507,0.034616694,-0.016872002,-0.010987958,-0.011953205)); 30 String indexName = "vector_index"; 31 FieldSearchPath fieldSearchPath = fieldPath("plot_embedding"); 32 int numCandidates = 150; 33 int limit = 10; 34 Bson criteria = Filters.and(Filters.gt("year", 1955), Filters.lt("year", 1975)); 35 VectorSearchOptions options = vectorSearchOptions().filter(criteria); 36 37 // define pipeline 38 List<Bson> pipeline = asList( 39 vectorSearch( 40 fieldSearchPath, 41 queryVector, 42 indexName, 43 numCandidates, 44 limit, 45 options), 46 project( 47 fields(exclude("_id"), include("title"), include("plot"), include("year"), 48 metaVectorSearchScore("score")))); 49 50 // run query and print results 51 collection.aggregate(pipeline) 52 .forEach(doc -> System.out.println(doc.toJson())); 53 } 54 } 55 }
1 {"plot": "In this magical tale about the boy who refuses to grow up, Peter Pan and his mischievous fairy sidekick Tinkerbell visit the nursery of Wendy, Michael, and John Darling. With a sprinkling ...", "title": "Peter Pan", "year": 1960, "score": 0.748110830783844} 2 {"plot": "A down-on-his-luck inventor turns a broken-down Grand Prix car into a fancy vehicle for his children, and then they go off on a magical fantasy adventure to save their grandfather in a far-off land.", "title": "Chitty Chitty Bang Bang", "year": 1968, "score": 0.7442465424537659} 3 {"plot": "A young man comes to the rescue of his girlfriend abducted by thieves and brought to Rio. An extravagant adventure ensues.", "title": "That Man from Rio", "year": 1964, "score": 0.7416020035743713} 4 {"plot": "A pilot, stranded in the desert, meets a little boy who is a prince on a planet.", "title": "The Little Prince", "year": 1974, "score": 0.7378944158554077} 5 {"plot": "A red balloon with a life of its own follows a little boy around the streets of Paris.", "title": "The Red Balloon", "year": 1956, "score": 0.7342712879180908} 6 {"plot": "A poor boy wins the opportunity to tour the most eccentric and wonderful candy factory of all.", "title": "Willy Wonka & the Chocolate Factory", "year": 1971, "score": 0.7342107892036438} 7 {"plot": "An apprentice witch, three kids and a cynical conman search for the missing component to a magic spell useful to the defense of Britain.", "title": "Bedknobs and Broomsticks", "year": 1971, "score": 0.7339356541633606} 8 {"plot": "A young boys' coming of age tale set in a strange, carnivalesque village becomes the recreation of a memory that the director has twenty years later.", "title": "Pastoral Hide and Seek", "year": 1974, "score": 0.733299970626831} 9 {"plot": "A young swordsman comes to Paris and faces villains, romance, adventure and intrigue with three Musketeer friends.", "title": "The Three Musketeers", "year": 1973, "score": 0.7331198453903198} 10 {"plot": "A fairy-tale about a conceited young man and a young woman with a tyrannical step-mother, who must overcome magical trials in order to be together.", "title": "Frosty", "year": 1964, "score": 0.7318308353424072}
Atlas Vector Search filters the documents based on the year
field value that
ranges between 1955 and 1975. It returns documents that summarize
children's adventures in the plot for movies released between 1955 and
1975.
Tip
See also: Additional Filter Examples
The How to Perform Semantic Search Against Data in Your Atlas Cluster tutorial demonstrates other
pre-filters in semantic search queries against the embedded data in
the sample_mflix.embedded_movies
collection.
The following query uses the $vectorSearch
stage to search
the plot_embedding
field using vector embeddings for the string
time travel. It considers up to 150
nearest neighbors, and
returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include only theplot
andtitle
fields in the results.Add a field named
score
that shows the vector search score for each document in the results.
1 const { MongoClient } = require("mongodb"); 2 3 // connect to your Atlas cluster 4 const uri = "<connection-string>"; 5 6 const client = new MongoClient(uri); 7 8 async function run() { 9 try { 10 await client.connect(); 11 12 // set namespace 13 const database = client.db("sample_mflix"); 14 const coll = database.collection("embedded_movies"); 15 16 // define pipeline 17 const agg = [ 18 { 19 '$vectorSearch': { 20 'index': 'vector_index', 21 'path': 'plot_embedding', 22 'queryVector': [ 23 -0.0016261312, -0.028070757, -0.011342932, -0.012775794, -0.0027440966, 0.008683807, -0.02575152, -0.02020668, -0.010283281, -0.0041719596, 0.021392956, 0.028657231, -0.006634482, 0.007490867, 0.018593878, 0.0038187427, 0.029590257, -0.01451522, 0.016061379, 0.00008528442, -0.008943722, 0.01627464, 0.024311995, -0.025911469, 0.00022596726, -0.008863748, 0.008823762, -0.034921836, 0.007910728, -0.01515501, 0.035801545, -0.0035688248, -0.020299982, -0.03145631, -0.032256044, -0.028763862, -0.0071576433, -0.012769129, 0.012322609, -0.006621153, 0.010583182, 0.024085402, -0.001623632, 0.007864078, -0.021406285, 0.002554159, 0.012229307, -0.011762793, 0.0051682983, 0.0048484034, 0.018087378, 0.024325324, -0.037694257, -0.026537929, -0.008803768, -0.017767483, -0.012642504, -0.0062712682, 0.0009771782, -0.010409906, 0.017754154, -0.004671795, -0.030469967, 0.008477209, -0.005218282, -0.0058480743, -0.020153364, -0.0032805866, 0.004248601, 0.0051449724, 0.006791097, 0.007650814, 0.003458861, -0.0031223053, -0.01932697, -0.033615597, 0.00745088, 0.006321252, -0.0038154104, 0.014555207, 0.027697546, -0.02828402, 0.0066711367, 0.0077107945, 0.01794076, 0.011349596, -0.0052715978, 0.014755142, -0.019753495, -0.011156326, 0.011202978, 0.022126047, 0.00846388, 0.030549942, -0.0041386373, 0.018847128, -0.00033655585, 0.024925126, -0.003555496, -0.019300312, 0.010749794, 0.0075308536, -0.018287312, -0.016567878, -0.012869096, -0.015528221, 0.0078107617, -0.011156326, 0.013522214, -0.020646535, -0.01211601, 0.055928253, 0.011596181, -0.017247654, 0.0005939711, -0.026977783, -0.003942035, -0.009583511, -0.0055248477, -0.028737204, 0.023179034, 0.003995351, 0.0219661, -0.008470545, 0.023392297, 0.010469886, -0.015874773, 0.007890735, -0.009690142, -0.00024970944, 0.012775794, 0.0114762215, 0.013422247, 0.010429899, -0.03686786, -0.006717788, -0.027484283, 0.011556195, -0.036068123, -0.013915418, -0.0016327957, 0.0151016945, -0.020473259, 0.004671795, -0.012555866, 0.0209531, 0.01982014, 0.024485271, 0.0105431955, -0.005178295, 0.033162415, -0.013795458, 0.007150979, 0.010243294, 0.005644808, 0.017260984, -0.0045618312, 0.0024725192, 0.004305249, -0.008197301, 0.0014203656, 0.0018460588, 0.005015015, -0.011142998, 0.01439526, 0.022965772, 0.02552493, 0.007757446, -0.0019726837, 0.009503538, -0.032042783, 0.008403899, -0.04609149, 0.013808787, 0.011749465, 0.036388017, 0.016314628, 0.021939443, -0.0250051, -0.017354285, -0.012962398, 0.00006107364, 0.019113706, 0.03081652, -0.018114036, -0.0084572155, 0.009643491, -0.0034721901, 0.0072642746, -0.0090636825, 0.01642126, 0.013428912, 0.027724205, 0.0071243206, -0.6858542, -0.031029783, -0.014595194, -0.011449563, 0.017514233, 0.01743426, 0.009950057, 0.0029706885, -0.015714826, -0.001806072, 0.011856096, 0.026444625, -0.0010663156, -0.006474535, 0.0016161345, -0.020313311, 0.0148351155, -0.0018393943, 0.0057347785, 0.018300641, -0.018647194, 0.03345565, -0.008070676, 0.0071443142, 0.014301958, 0.0044818576, 0.003838736, -0.007350913, -0.024525259, -0.001142124, -0.018620536, 0.017247654, 0.007037683, 0.010236629, 0.06046009, 0.0138887605, -0.012122675, 0.037694257, 0.0055081863, 0.042492677, 0.00021784494, -0.011656162, 0.010276617, 0.022325981, 0.005984696, -0.009496873, 0.013382261, -0.0010563189, 0.0026507939, -0.041639622, 0.008637156, 0.026471283, -0.008403899, 0.024858482, -0.00066686375, -0.0016252982, 0.027590916, 0.0051449724, 0.0058647357, -0.008743787, -0.014968405, 0.027724205, -0.011596181, 0.0047650975, -0.015381602, 0.0043718936, 0.002159289, 0.035908177, -0.008243952, -0.030443309, 0.027564257, 0.042625964, -0.0033688906, 0.01843393, 0.019087048, 0.024578573, 0.03268257, -0.015608194, -0.014128681, -0.0033538956, -0.0028757197, -0.004121976, -0.032389335, 0.0034322033, 0.058807302, 0.010943064, -0.030523283, 0.008903735, 0.017500903, 0.00871713, -0.0029406983, 0.013995391, -0.03132302, -0.019660193, -0.00770413, -0.0038853872, 0.0015894766, -0.0015294964, -0.006251275, -0.021099718, -0.010256623, -0.008863748, 0.028550599, 0.02020668, -0.0012962399, -0.003415542, -0.0022509254, 0.0119360695, 0.027590916, -0.046971202, -0.0015194997, -0.022405956, 0.0016677842, -0.00018535563, -0.015421589, -0.031802863, 0.03814744, 0.0065411795, 0.016567878, -0.015621523, 0.022899127, -0.011076353, 0.02841731, -0.002679118, -0.002342562, 0.015341615, 0.01804739, -0.020566562, -0.012989056, -0.002990682, 0.01643459, 0.00042527664, 0.008243952, -0.013715484, -0.004835075, -0.009803439, 0.03129636, -0.021432944, 0.0012087687, -0.015741484, -0.0052016205, 0.00080890034, -0.01755422, 0.004811749, -0.017967418, -0.026684547, -0.014128681, 0.0041386373, -0.013742141, -0.010056688, -0.013268964, -0.0110630235, -0.028337335, 0.015981404, -0.00997005, -0.02424535, -0.013968734, -0.028310679, -0.027750863, -0.020699851, 0.02235264, 0.001057985, 0.00081639783, -0.0099367285, 0.013522214, -0.012016043, -0.00086471526, 0.013568865, 0.0019376953, -0.019020405, 0.017460918, -0.023045745, 0.008503866, 0.0064678704, -0.011509543, 0.018727167, -0.003372223, -0.0028690554, -0.0027024434, -0.011902748, -0.012182655, -0.015714826, -0.0098634185, 0.00593138, 0.018753825, 0.0010146659, 0.013029044, 0.0003521757, -0.017620865, 0.04102649, 0.00552818, 0.024485271, -0.009630162, -0.015608194, 0.0006718621, -0.0008418062, 0.012395918, 0.0057980907, 0.016221326, 0.010616505, 0.004838407, -0.012402583, 0.019900113, -0.0034521967, 0.000247002, -0.03153628, 0.0011038032, -0.020819811, 0.016234655, -0.00330058, -0.0032289368, 0.00078973995, -0.021952773, -0.022459272, 0.03118973, 0.03673457, -0.021472929, 0.0072109587, -0.015075036, 0.004855068, -0.0008151483, 0.0069643734, 0.010023367, -0.010276617, -0.023019087, 0.0068244194, -0.0012520878, -0.0015086699, 0.022046074, -0.034148756, -0.0022192693, 0.002427534, -0.0027124402, 0.0060346797, 0.015461575, 0.0137554705, 0.009230294, -0.009583511, 0.032629255, 0.015994733, -0.019167023, -0.009203636, 0.03393549, -0.017274313, -0.012042701, -0.0009930064, 0.026777849, -0.013582194, -0.0027590916, -0.017594207, -0.026804507, -0.0014236979, -0.022032745, 0.0091236625, -0.0042419364, -0.00858384, -0.0033905501, -0.020739838, 0.016821127, 0.022539245, 0.015381602, 0.015141681, 0.028817179, -0.019726837, -0.0051283115, -0.011489551, -0.013208984, -0.0047017853, -0.0072309524, 0.01767418, 0.0025658219, -0.010323267, 0.012609182, -0.028097415, 0.026871152, -0.010276617, 0.021912785, 0.0022542577, 0.005124979, -0.0019710176, 0.004518512, -0.040360045, 0.010969722, -0.0031539614, -0.020366628, -0.025778178, -0.0110030435, -0.016221326, 0.0036587953, 0.016207997, 0.003007343, -0.0032555948, 0.0044052163, -0.022046074, -0.0008822095, -0.009363583, 0.028230704, -0.024538586, 0.0029840174, 0.0016044717, -0.014181997, 0.031349678, -0.014381931, -0.027750863, 0.02613806, 0.0004136138, -0.005748107, -0.01868718, -0.0010138329, 0.0054348772, 0.010703143, -0.003682121, 0.0030856507, -0.004275259, -0.010403241, 0.021113047, -0.022685863, -0.023032416, 0.031429652, 0.001792743, -0.005644808, -0.011842767, -0.04078657, -0.0026874484, 0.06915057, -0.00056939584, -0.013995391, 0.010703143, -0.013728813, -0.022939114, -0.015261642, -0.022485929, 0.016807798, 0.007964044, 0.0144219175, 0.016821127, 0.0076241563, 0.005461535, -0.013248971, 0.015301628, 0.0085171955, -0.004318578, 0.011136333, -0.0059047225, -0.010249958, -0.018207338, 0.024645219, 0.021752838, 0.0007614159, -0.013648839, 0.01111634, -0.010503208, -0.0038487327, -0.008203966, -0.00397869, 0.0029740208, 0.008530525, 0.005261601, 0.01642126, -0.0038753906, -0.013222313, 0.026537929, 0.024671877, -0.043505676, 0.014195326, 0.024778508, 0.0056914594, -0.025951454, 0.017620865, -0.0021359634, 0.008643821, 0.021299653, 0.0041686273, -0.009017031, 0.04044002, 0.024378639, -0.027777521, -0.014208655, 0.0028623908, 0.042119466, 0.005801423, -0.028124074, -0.03129636, 0.022139376, -0.022179363, -0.04067994, 0.013688826, 0.013328944, 0.0046184794, -0.02828402, -0.0063412455, -0.0046184794, -0.011756129, -0.010383247, -0.0018543894, -0.0018593877, -0.00052024535, 0.004815081, 0.014781799, 0.018007403, 0.01306903, -0.020433271, 0.009043689, 0.033189073, -0.006844413, -0.019766824, -0.018767154, 0.00533491, -0.0024575242, 0.018727167, 0.0058080875, -0.013835444, 0.0040719924, 0.004881726, 0.012029372, 0.005664801, 0.03193615, 0.0058047553, 0.002695779, 0.009290274, 0.02361889, 0.017834127, 0.0049017193, -0.0036388019, 0.010776452, -0.019793482, 0.0067777685, -0.014208655, -0.024911797, 0.002385881, 0.0034988478, 0.020899786, -0.0025858153, -0.011849431, 0.033189073, -0.021312982, 0.024965113, -0.014635181, 0.014048708, -0.0035921505, -0.003347231, 0.030869836, -0.0017161017, -0.0061346465, 0.009203636, -0.025165047, 0.0068510775, 0.021499587, 0.013782129, -0.0024475274, -0.0051149824, -0.024445284, 0.006167969, 0.0068844, -0.00076183246, 0.030150073, -0.0055948244, -0.011162991, -0.02057989, -0.009703471, -0.020646535, 0.008004031, 0.0066378145, -0.019900113, -0.012169327, -0.01439526, 0.0044252095, -0.004018677, 0.014621852, -0.025085073, -0.013715484, -0.017980747, 0.0071043274, 0.011456228, -0.01010334, -0.0035321703, -0.03801415, -0.012036037, -0.0028990454, -0.05419549, -0.024058744, -0.024272008, 0.015221654, 0.027964126, 0.03182952, -0.015354944, 0.004855068, 0.011522872, 0.004771762, 0.0027874154, 0.023405626, 0.0004242353, -0.03132302, 0.007057676, 0.008763781, -0.0027057757, 0.023005757, -0.0071176565, -0.005238275, 0.029110415, -0.010989714, 0.013728813, -0.009630162, -0.029137073, -0.0049317093, -0.0008630492, -0.015248313, 0.0043219104, -0.0055681667, -0.013175662, 0.029723546, 0.025098402, 0.012849103, -0.0009996708, 0.03118973, -0.0021709518, 0.0260181, -0.020526575, 0.028097415, -0.016141351, 0.010509873, -0.022965772, 0.002865723, 0.0020493253, 0.0020509914, -0.0041419696, -0.00039695262, 0.017287642, 0.0038987163, 0.014795128, -0.014661839, -0.008950386, 0.004431874, -0.009383577, 0.0012604183, -0.023019087, 0.0029273694, -0.033135757, 0.009176978, -0.011023037, -0.002102641, 0.02663123, -0.03849399, -0.0044152127, 0.0004527676, -0.0026924468, 0.02828402, 0.017727496, 0.035135098, 0.02728435, -0.005348239, -0.001467017, -0.019766824, 0.014715155, 0.011982721, 0.0045651635, 0.023458943, -0.0010046692, -0.0031373003, -0.0006972704, 0.0019043729, -0.018967088, -0.024311995, 0.0011546199, 0.007977373, -0.004755101, -0.010016702, -0.02780418, -0.004688456, 0.013022379, -0.005484861, 0.0017227661, -0.015394931, -0.028763862, -0.026684547, 0.0030589928, -0.018513903, 0.028363993, 0.0044818576, -0.009270281, 0.038920518, -0.016008062, 0.0093902415, 0.004815081, -0.021059733, 0.01451522, -0.0051583014, 0.023765508, -0.017874114, -0.016821127, -0.012522544, -0.0028390652, 0.0040886537, 0.020259995, -0.031216389, -0.014115352, -0.009176978, 0.010303274, 0.020313311, 0.0064112223, -0.02235264, -0.022872468, 0.0052449396, 0.0005723116, 0.0037321046, 0.016807798, -0.018527232, -0.009303603, 0.0024858483, -0.0012662497, -0.007110992, 0.011976057, -0.007790768, -0.042999174, -0.006727785, -0.011829439, 0.007024354, 0.005278262, -0.017740825, -0.0041519664, 0.0085905045, 0.027750863, -0.038387362, 0.024391968, 0.00087721116, 0.010509873, -0.00038508154, -0.006857742, 0.0183273, -0.0037054466, 0.015461575, 0.0017394272, -0.0017944091, 0.014181997, -0.0052682655, 0.009023695, 0.00719763, -0.013522214, 0.0034422, 0.014941746, -0.0016711164, -0.025298337, -0.017634194, 0.0058714002, -0.005321581, 0.017834127, 0.0110630235, -0.03369557, 0.029190388, -0.008943722, 0.009363583, -0.0034222065, -0.026111402, -0.007037683, -0.006561173, 0.02473852, -0.007084334, -0.010110005, -0.008577175, 0.0030439978, -0.022712521, 0.0054582027, -0.0012620845, -0.0011954397, -0.015741484, 0.0129557345, -0.00042111133, 0.00846388, 0.008930393, 0.016487904, 0.010469886, -0.007917393, -0.011762793, -0.0214596, 0.000917198, 0.021672864, 0.010269952, -0.007737452, -0.010243294, -0.0067244526, -0.015488233, -0.021552904, 0.017127695, 0.011109675, 0.038067464, 0.00871713, -0.0025591573, 0.021312982, -0.006237946, 0.034628596, -0.0045251767, 0.008357248, 0.020686522, 0.0010696478, 0.0076708077, 0.03772091, -0.018700508, -0.0020676525, -0.008923728, -0.023298996, 0.018233996, -0.010256623, 0.0017860786, 0.009796774, -0.00897038, -0.01269582, -0.018527232, 0.009190307, -0.02372552, -0.042119466, 0.008097334, -0.0066778013, -0.021046404, 0.0019593548, 0.011083017, -0.0016028056, 0.012662497, -0.000059095124, 0.0071043274, -0.014675168, 0.024831824, -0.053582355, 0.038387362, 0.0005698124, 0.015954746, 0.021552904, 0.031589597, -0.009230294, -0.0006147976, 0.002625802, -0.011749465, -0.034362018, -0.0067844326, -0.018793812, 0.011442899, -0.008743787, 0.017474247, -0.021619547, 0.01831397, -0.009037024, -0.0057247817, -0.02728435, 0.010363255, 0.034415334, -0.024032086, -0.0020126705, -0.0045518344, -0.019353628, -0.018340627, -0.03129636, -0.0034038792, -0.006321252, -0.0016161345, 0.033642255, -0.000056075285, -0.005005019, 0.004571828, -0.0024075406, -0.00010215386, 0.0098634185, 0.1980148, -0.003825407, -0.025191706, 0.035161756, 0.005358236, 0.025111731, 0.023485601, 0.0023342315, -0.011882754, 0.018287312, -0.0068910643, 0.003912045, 0.009243623, -0.001355387, -0.028603915, -0.012802451, -0.030150073, -0.014795128, -0.028630573, -0.0013487226, 0.002667455, 0.00985009, -0.0033972147, -0.021486258, 0.009503538, -0.017847456, 0.013062365, -0.014341944, 0.005078328, 0.025165047, -0.015594865, -0.025924796, -0.0018177348, 0.010996379, -0.02993681, 0.007324255, 0.014475234, -0.028577257, 0.005494857, 0.00011725306, -0.013315615, 0.015941417, 0.009376912, 0.0025158382, 0.008743787, 0.023832154, -0.008084005, -0.014195326, -0.008823762, 0.0033455652, -0.032362677, -0.021552904, -0.0056081535, 0.023298996, -0.025444955, 0.0097301295, 0.009736794, 0.015274971, -0.0012937407, -0.018087378, -0.0039387033, 0.008637156, -0.011189649, -0.00023846315, -0.011582852, 0.0066411467, -0.018220667, 0.0060846633, 0.0376676, -0.002709108, 0.0072776037, 0.0034188742, -0.010249958, -0.0007747449, -0.00795738, -0.022192692, 0.03910712, 0.032122757, 0.023898797, 0.0076241563, -0.007397564, -0.003655463, 0.011442899, -0.014115352, -0.00505167, -0.031163072, 0.030336678, -0.006857742, -0.022259338, 0.004048667, 0.02072651, 0.0030156737, -0.0042119464, 0.00041861215, -0.005731446, 0.011103011, 0.013822115, 0.021512916, 0.009216965, -0.006537847, -0.027057758, -0.04054665, 0.010403241, -0.0056281467, -0.005701456, -0.002709108, -0.00745088, -0.0024841821, 0.009356919, -0.022659205, 0.004061996, -0.013175662, 0.017074378, -0.006141311, -0.014541878, 0.02993681, -0.00028448965, -0.025271678, 0.011689484, -0.014528549, 0.004398552, -0.017274313, 0.0045751603, 0.012455898, 0.004121976, -0.025458284, -0.006744446, 0.011822774, -0.015035049, -0.03257594, 0.014675168, -0.0039187097, 0.019726837, -0.0047251107, 0.0022825818, 0.011829439, 0.005391558, -0.016781142, -0.0058747325, 0.010309938, -0.013049036, 0.01186276, -0.0011246296, 0.0062112883, 0.0028190718, -0.021739509, 0.009883412, -0.0073175905, -0.012715813, -0.017181009, -0.016607866, -0.042492677, -0.0014478565, -0.01794076, 0.012302616, -0.015194997, -0.04433207, -0.020606548, 0.009696807, 0.010303274, -0.01694109, -0.004018677, 0.019353628, -0.001991011, 0.000058938927, 0.010536531, -0.17274313, 0.010143327, 0.014235313, -0.024152048, 0.025684876, -0.0012504216, 0.036601283, -0.003698782, 0.0007310093, 0.004165295, -0.0029157067, 0.017101036, -0.046891227, -0.017460918, 0.022965772, 0.020233337, -0.024072073, 0.017220996, 0.009370248, 0.0010363255, 0.0194336, -0.019606877, 0.01818068, -0.020819811, 0.007410893, 0.0019326969, 0.017887443, 0.006651143, 0.00067394477, -0.011889419, -0.025058415, -0.008543854, 0.021579562, 0.0047484366, 0.014062037, 0.0075508473, -0.009510202, -0.009143656, 0.0046817916, 0.013982063, -0.0027990784, 0.011782787, 0.014541878, -0.015701497, -0.029350337, 0.021979429, 0.01332228, -0.026244693, -0.0123492675, -0.003895384, 0.0071576433, -0.035454992, -0.00046984528, 0.0033522295, 0.039347045, 0.0005119148, 0.00476843, -0.012995721, 0.0024042083, -0.006931051, -0.014461905, -0.0127558, 0.0034555288, -0.0074842023, -0.030256703, -0.007057676, -0.00807734, 0.007804097, -0.006957709, 0.017181009, -0.034575284, -0.008603834, -0.005008351, -0.015834786, 0.02943031, 0.016861115, -0.0050849924, 0.014235313, 0.0051449724, 0.0025924798, -0.0025741523, 0.04289254, -0.002104307, 0.012969063, -0.008310596, 0.00423194, 0.0074975314, 0.0018810473, -0.014248641, -0.024725191, 0.0151016945, -0.017527562, 0.0018727167, 0.0002830318, 0.015168339, 0.0144219175, -0.004048667, -0.004358565, 0.011836103, -0.010343261, -0.005911387, 0.0022825818, 0.0073175905, 0.00403867, 0.013188991, 0.03334902, 0.006111321, 0.008597169, 0.030123414, -0.015474904, 0.0017877447, -0.024551915, 0.013155668, 0.023525586, -0.0255116, 0.017220996, 0.004358565, -0.00934359, 0.0099967085, 0.011162991, 0.03092315, -0.021046404, -0.015514892, 0.0011946067, -0.01816735, 0.010876419, -0.10124666, -0.03550831, 0.0056348112, 0.013942076, 0.005951374, 0.020419942, -0.006857742, -0.020873128, -0.021259667, 0.0137554705, 0.0057880944, -0.029163731, -0.018767154, -0.021392956, 0.030896494, -0.005494857, -0.0027307675, -0.006801094, -0.014821786, 0.021392956, -0.0018110704, -0.0018843795, -0.012362596, -0.0072176233, -0.017194338, -0.018713837, -0.024272008, 0.03801415, 0.00015880188, 0.0044951867, -0.028630573, -0.0014070367, -0.00916365, -0.026537929, -0.009576847, -0.013995391, -0.0077107945, 0.0050016865, 0.00578143, -0.04467862, 0.008363913, 0.010136662, -0.0006268769, -0.006591163, 0.015341615, -0.027377652, -0.00093136, 0.029243704, -0.020886457, -0.01041657, -0.02424535, 0.005291591, -0.02980352, -0.009190307, 0.019460259, -0.0041286405, 0.004801752, 0.0011787785, -0.001257086, -0.011216307, -0.013395589, 0.00088137644, -0.0051616337, 0.03876057, -0.0033455652, 0.00075850025, -0.006951045, -0.0062112883, 0.018140694, -0.006351242, -0.008263946, 0.018154023, -0.012189319, 0.0075508473, -0.044358727, -0.0040153447, 0.0093302615, -0.010636497, 0.032789204, -0.005264933, -0.014235313, -0.018393943, 0.007297597, -0.016114693, 0.015021721, 0.020033404, 0.0137688, 0.0011046362, 0.010616505, -0.0039453674, 0.012109346, 0.021099718, -0.0072842683, -0.019153694, -0.003768759, 0.039320387, -0.006747778, -0.0016852784, 0.018154023, 0.0010963057, -0.015035049, -0.021033075, -0.04345236, 0.017287642, 0.016341286, -0.008610498, 0.00236922, 0.009290274, 0.028950468, -0.014475234, -0.0035654926, 0.015434918, -0.03372223, 0.004501851, -0.012929076, -0.008483873, -0.0044685286, -0.0102233, 0.01615468, 0.0022792495, 0.010876419, -0.0059647025, 0.01895376, -0.0069976957, -0.0042952523, 0.017207667, -0.00036133936, 0.0085905045, 0.008084005, 0.03129636, -0.016994404, -0.014915089, 0.020100048, -0.012009379, -0.006684466, 0.01306903, 0.00015765642, -0.00530492, 0.0005277429, 0.015421589, 0.015528221, 0.032202728, -0.003485519, -0.0014286962, 0.033908837, 0.001367883, 0.010509873, 0.025271678, -0.020993087, 0.019846799, 0.006897729, -0.010216636, -0.00725761, 0.01818068, -0.028443968, -0.011242964, -0.014435247, -0.013688826, 0.006101324, -0.0022509254, 0.013848773, -0.0019077052, 0.017181009, 0.03422873, 0.005324913, -0.0035188415, 0.014128681, -0.004898387, 0.005038341, 0.0012320944, -0.005561502, -0.017847456, 0.0008538855, -0.0047884234, 0.011849431, 0.015421589, -0.013942076, 0.0029790192, -0.013702155, 0.0001199605, -0.024431955, 0.019926772, 0.022179363, -0.016487904, -0.03964028, 0.0050849924, 0.017487574, 0.022792496, 0.0012504216, 0.004048667, -0.00997005, 0.0076041627, -0.014328616, -0.020259995, 0.0005598157, -0.010469886, 0.0016852784, 0.01716768, -0.008990373, -0.001987679, 0.026417969, 0.023792166, 0.0046917885, -0.0071909656, -0.00032051947, -0.023259008, -0.009170313, 0.02071318, -0.03156294, -0.030869836, -0.006324584, 0.013795458, -0.00047151142, 0.016874444, 0.00947688, 0.00985009, -0.029883493, 0.024205362, -0.013522214, -0.015075036, -0.030603256, 0.029270362, 0.010503208, 0.021539574, 0.01743426, -0.023898797, 0.022019416, -0.0068777353, 0.027857494, -0.021259667, 0.0025758184, 0.006197959, 0.006447877, -0.00025200035, -0.004941706, -0.021246338, -0.005504854, -0.008390571, -0.0097301295, 0.027244363, -0.04446536, 0.05216949, 0.010243294, -0.016008062, 0.0122493, -0.0199401, 0.009077012, 0.019753495, 0.006431216, -0.037960835, -0.027377652, 0.016381273, -0.0038620618, 0.022512587, -0.010996379, -0.0015211658, -0.0102233, 0.007071005, 0.008230623, -0.009490209, -0.010083347, 0.024431955, 0.002427534, 0.02828402, 0.0035721571, -0.022192692, -0.011882754, 0.010056688, 0.0011904413, -0.01426197, -0.017500903, -0.00010985966, 0.005591492, -0.0077707744, -0.012049366, 0.011869425, 0.00858384, -0.024698535, -0.030283362, 0.020140035, 0.011949399, -0.013968734, 0.042732596, -0.011649498, -0.011982721, -0.016967745, -0.0060913274, -0.007130985, -0.013109017, -0.009710136 24 ], 25 'numCandidates': 150, 26 'limit': 10 27 } 28 }, { 29 '$project': { 30 '_id': 0, 31 'plot': 1, 32 'title': 1, 33 'score': { 34 '$meta': 'vectorSearchScore' 35 } 36 } 37 } 38 ]; 39 // run pipeline 40 const result = coll.aggregate(agg); 41 42 // print results 43 await result.forEach((doc) => console.dir(JSON.stringify(doc))); 44 } finally { 45 await client.close(); 46 } 47 } 48 run().catch(console.dir);
1 '{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7892671227455139}' 2 '{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7843604683876038}' 3 '{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7801066637039185}' 4 `{"plot":"After using his mother's newly built time machine, Dolf gets stuck involuntary in the year 1212. He ends up in a children's crusade where he confronts his new friends with modern techniques...","title":"Crusade in Jeans","score":0.7789170742034912}` 5 '{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7771612405776978}' 6 '{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7730885744094849}' 7 `{"plot":"Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.","title":"Men in Black 3","score":0.7712380886077881}` 8 '{"plot":"Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.","title":"Tomorrowland","score":0.7669923901557922}' 9 '{"plot":"With the help of his uncle, a man travels to the future to try and bring his girlfriend back to life.","title":"Love Story 2050","score":0.7649372816085815}' 10 '{"plot":"A dimension-traveling wizard gets stuck in the 21st century because cell-phone radiation interferes with his magic. With his home world on the brink of war, he seeks help from a jaded ...","title":"The Portal","score":0.7640786170959473}'
The following query filters the documents for movies released between
January 01, 1955
and January 01, 1975
before performing the
semantic search against the sample vector data. It uses the
$and
operator to perform a logical AND
operation of the
specified dates. It then searches the plot_embedding
field in the
filtered documents for 150
nearest neighbors using the vector
embeddings for the string kids adventure, and returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include onlyplot
,title
, andyear
fields in the results.Add a field named
score
that shows the vector search score of the documents in the results.
1 const { MongoClient } = require("mongodb"); 2 3 // connect to your Atlas cluster 4 const uri = "<connection-string>"; 5 6 const client = new MongoClient(uri); 7 8 async function run() { 9 try { 10 await client.connect(); 11 12 // set namespace 13 const database = client.db("sample_mflix"); 14 const coll = database.collection("embedded_movies"); 15 16 // define pipeline 17 const agg = [ 18 { 19 '$vectorSearch': { 20 'index': 'vector_index', 21 'path': 'plot_embedding', 22 'filter': { 23 '$and': [ 24 { 25 'year': { 26 '$gt': 1955 27 }, 28 'year': { 29 '$lt': 1975 30 } 31 } 32 ] 33 }, 34 'queryVector': [0.02421053, -0.022372592, -0.006231137, -0.02168502, -0.020375984, 0.037552103, -0.010505334, -0.027026938, 0.0070674648, -0.020032197, 0.01783725, 0.016303431, 0.014584498, -0.018736385, 0.009031017, -0.0045981496, 0.02750295, -0.028322749, 0.010624337, -0.024236975, -0.0048659067, 0.015153068, -0.000490888, -0.022161031, -0.0024560927, -0.007411252, 0.009745035, -0.01886861, 0.02112967, -0.011939983, 0.015153068, 0.0025800543, 0.017824028, -0.02410475, -0.016633997, -0.0018214093, -0.008323609, -0.009222744, 0.009388026, -0.0028296304, 0.0017536436, 0.0065517845, -0.011635863, -0.028454976, -0.018934723, 0.012951509, -0.0032015154, -0.005880739, -0.03115238, 0.012951509, 0.0057749585, 0.009202911, -0.0069352393, 0.00205611, 0.0063732797, 0.0039700773, -0.007100521, -0.0077087595, 0.011596196, -0.010207825, -0.007100521, -0.0051006074, -0.01670011, 0.012773004, -0.035304267, -0.0074971984, 0.0025800543, -0.006118745, 0.030253245, -0.0010751605, 0.039456155, 0.007821151, -0.0017189344, -0.0010801188, 0.0062575825, -0.011490415, -0.022637043, 0.004743598, -0.012601111, 0.0197413, -0.0015255542, -0.025942687, -0.03284487, 0.020389207, 0.009797926, 0.0141217075, -0.0015172901, 0.025982354, -0.011589585, -0.001138794, 0.0006131968, 0.016832335, 0.017916586, 0.014412603, -0.0027155858, 0.011854036, -0.02169824, 0.02112967, -0.020680103, -0.007391418, -0.012872174, 0.021473458, 0.0047766543, -0.0048394613, -0.024395647, 0.0065418677, 0.009797926, -0.00449898, 0.041836217, 0.0023833686, -0.021737909, 0.0136721395, 0.014148152, -0.028772317, -0.027899627, -0.015695194, -0.012521776, 0.02205525, -0.01927851, -0.022068473, 0.020971, 0.02317917, 0.030544141, -0.011827591, 0.0075170323, 0.023086611, -0.02164535, -0.01732157, 0.007510421, -0.027635176, 0.016263764, -0.0008801275, 0.033109322, -0.014505162, -0.029909458, 0.036679417, 0.0074971984, 0.0059137954, -0.031178825, -0.012634167, 0.008416167, 0.030491251, -0.016832335, -0.009507029, 0.010016099, 0.009778093, 0.007840985, 0.010928456, -0.009685534, -0.027661622, 0.024752656, -0.024871659, 0.01516629, 0.002778393, 0.0059501575, 0.022042029, 0.0005441915, 0.0076889256, -0.009883873, -0.019966085, 0.008508725, 0.0098045375, 0.0091169635, -0.02750295, 0.012501942, 0.03480181, 0.021751132, 0.020746216, 0.003546955, -0.014690278, 0.010445832, 0.008469057, -0.00007535833, 0.0059600743, -0.013526691, 0.029539226, -0.011126795, 0.025400562, -0.025466675, -0.0046080663, -0.013923368, -0.009011183, 0.019318178, 0.019053727, -0.012085431, -0.0074707535, 0.0013024234, 0.0076624807, 0.0060460214, -0.0023007276, 0.017757915, 0.031258162, 0.0008768218, -0.003695709, -0.6981518, -0.012058986, 0.008931847, -0.02914255, 0.00833022, 0.028349195, 0.013857256, 0.0029668147, -0.008164939, -0.001494977, -0.0011197866, 0.0104855, 0.014610942, -0.0066608707, 0.000643774, 0.0020676798, 0.008607894, -0.023787407, 0.020494986, 0.015443964, -0.019833859, 0.012905231, 0.013387854, -0.020918109, 0.0035800114, 0.026775708, 0.005920407, -0.018233927, -0.008759954, 0.0005437783, -0.022081695, 0.0071996907, -0.002963509, 0.004092386, 0.057967756, -0.015285294, -0.008978127, 0.027740957, 0.015853863, 0.047178138, -0.018366152, -0.0064889775, 0.029777233, 0.0141217075, 0.007847597, 0.02200236, 0.031125935, 0.010611114, -0.00663112, -0.005940241, 0.017215788, -0.019992528, -0.01644888, -0.013447356, 0.001490845, 0.007893875, 0.016276987, -0.0062939445, 0.00032333322, 0.0020230536, -0.025360893, 0.028587202, -0.009645866, 0.01459772, -0.012376328, 0.03202507, -0.006059244, 0.010888788, 0.014518384, -0.034405135, 0.023364285, 0.018895056, -0.009361581, -0.0011255714, 0.00663112, 0.016885225, 0.01609187, -0.006750123, -0.035304267, 0.0022660184, 0.027714511, 0.01680589, -0.03686453, -0.008045935, 0.052943178, -0.0091169635, -0.0066840104, 0.018405821, 0.00027374856, 0.0005235312, 0.0138969235, 0.018075256, 0.0005850988, -0.0074971984, 0.0011255714, -0.011054071, -0.0022048638, 0.0043931995, 0.021142893, -0.02472621, -0.007232747, 0.0014858865, -0.00062228733, -0.017903363, -0.0013495288, -0.0001454483, 0.0027370725, 0.0060129645, 0.0364943, -0.04601455, -0.008713675, -0.017215788, -0.017784359, -0.007100521, -0.014610942, -0.027978962, 0.0046179835, -0.010267328, 0.036785197, -0.019542962, 0.028719427, 0.004343615, 0.0067765685, -0.018075256, -0.004462618, 0.010121879, -0.0024957606, -0.00883929, 0.0017007533, -0.011371412, -0.007788095, 0.002418078, -0.01053839, -0.018458711, -0.0048328503, 0.0035072872, 0.0043568374, -0.006389808, 0.027635176, -0.002768476, -0.033479553, -0.0069749067, -0.00096276856, -0.0034048124, 0.012773004, -0.01979419, -0.003675875, -0.011655698, -0.026709596, -0.0009206216, -0.009295468, 0.011391246, 0.0050510224, 0.0027486421, 0.0024246892, -0.01264739, 0.004687402, -0.0058377655, 0.0117945345, -0.009388026, 0.010545001, 0.020481765, -0.000089768866, -0.022425482, -0.013487023, -0.008316998, -0.019503294, 0.025942687, 0.0076889256, -0.03355889, -0.0071071326, -0.019106617, -0.015430742, 0.021724686, 0.0019652047, 0.011113572, -0.019410737, -0.023615515, 0.000523118, 0.019027282, -0.015853863, -0.011887092, -0.021804022, -0.013473801, -0.0049518533, -0.00071773777, -0.003194904, 0.046411227, -0.0108689545, 0.04003795, -0.0026626955, 0.03146972, -0.005804709, -0.013645695, 0.0046973187, -0.010148324, 0.02292794, 0.0310466, 0.018709939, 0.020005751, 0.028534312, -0.02134123, 0.044031166, -0.00021548661, 0.018458711, -0.038795028, -0.00930208, -0.013738252, 0.029486336, -0.0019503294, 0.008812845, -0.02755584, 0.004852684, -0.013301908, 0.000006940559, 0.017453795, -0.005249361, 0.0069352393, -0.023205614, -0.02040243, -0.0060493266, -0.017110009, 0.011417692, 0.006882349, -0.019556185, 0.015893532, -0.0028874793, -0.0023387424, -0.0034610082, -0.009427694, -0.009705368, 0.002194947, -0.008191383, 0.021804022, -0.016250541, 0.0053320024, 0.037393436, -0.014174597, 0.031073045, 0.004108914, 0.010029321, 0.018538047, 0.007675703, -0.012568055, -0.0080525465, 0.0013487024, 0.03234241, -0.009983042, -0.014782836, 0.0069418503, -0.014346491, -0.0009875608, -0.024924548, 0.035145596, 0.009592976, -0.010902011, 0.0047568204, 0.006194775, 0.011344967, 0.028349195, 0.0062410543, -0.0027172386, 0.011080516, 0.012303604, 0.012263936, -0.009844205, -0.004766737, -0.0062079974, -0.005748513, -0.01979419, -0.006036104, -0.018630605, -0.00050204457, -0.013830811, 0.0015338184, -0.00418825, -0.020799106, -0.016792666, -0.0034015067, 0.034352243, 0.00915002, -0.019767746, 0.016462103, 0.014346491, -0.009672312, -0.032606862, -0.010035932, -0.0035238154, -0.018934723, 0.012204434, -0.015946422, 0.022597376, -0.00081194856, 0.002740378, 0.0088921795, 0.0056361216, 0.011549917, -0.0088789575, 0.008720286, 0.007424474, -0.0022263506, 0.0020131366, -0.023165947, -0.037181873, 0.014756391, 0.011424302, -0.0057385964, -0.014690278, -0.018709939, -0.005536952, -0.0064228643, 0.00418825, -0.023787407, 0.012845729, -0.009487196, -0.011754867, -0.008746731, -0.013844033, 0.026643483, 0.009070684, -0.016554661, -0.024078304, -0.013553137, 0.011146628, 0.11075226, -0.007854208, 0.0024098137, 0.005685706, 0.0032081266, -0.00603941, -0.022161031, 0.0004933672, 0.0014486981, -0.001134662, 0.007345139, 0.008237663, -0.0019057032, 0.007120355, -0.009864039, 0.03115238, -0.00041051954, -0.00344448, -0.013063901, -0.020997444, 0.013222572, -0.002824672, 0.018366152, 0.025889797, 0.007523644, -0.019648742, -0.007391418, 0.02168502, -0.0019255371, -0.018524824, -0.00021156116, -0.004826239, -0.001088383, -0.0071468004, 0.0000106013, -0.002963509, 0.015430742, 0.029036768, 0.035806727, -0.016924892, 0.039271038, 0.02503033, 0.019648742, -0.02636581, 0.0035634832, -0.00044254295, -0.016435657, 0.012792839, 0.008270719, -0.03469603, 0.052599393, 0.008270719, -0.0052824174, -0.0059534633, 0.023668405, 0.011159851, -0.018128147, -0.0064856717, 0.009606198, -0.015258849, 0.00291723, -0.028851653, 0.019133061, -0.012323437, -0.01516629, -0.027846737, -0.019820636, 0.0024974134, -0.01377792, -0.00067063235, -0.022703156, -0.009156631, -0.012303604, -0.023311395, 0.006174941, 0.0073980293, 0.012343272, -0.015721638, -0.00033097752, 0.019146284, 0.011761478, -0.019542962, -0.0057452074, -0.0076823146, -0.002343701, 0.007840985, 0.014941507, 0.007847597, -0.004029579, 0.008812845, 0.029168995, 0.01876283, 0.01125902, -0.010611114, 0.00021734604, -0.0037948783, -0.0016445575, 0.028587202, 0.015086955, 0.0035899284, 0.0009900401, -0.019622298, -0.00704102, -0.0062410543, 0.0027106274, 0.009652478, -0.01573486, 0.0152985165, 0.0046774847, -0.02595591, 0.0115565285, -0.021989137, 0.010961512, -0.011179685, 0.011781312, -0.00055782724, -0.0033238241, -0.0012619293, 0.02066688, -0.014372936, 0.006399725, -0.022332925, 0.011014403, 0.01927851, -0.008733509, 0.003798184, 0.017744692, -0.036732305, 0.0077087595, 0.005454311, -0.0038676024, 0.01696456, -0.00037973575, 0.0058212373, -0.030517697, -0.012006096, 0.012482109, 0.015946422, 0.0031899456, 0.001283416, -0.0055898423, 0.01737446, 0.03633563, 0.015642302, -0.002953592, -0.02446176, -0.011364801, -0.023033721, -0.003798184, 0.03726121, -0.021513125, 0.014505162, -0.008971515, -0.0023007276, 0.0009231008, -0.03916526, -0.023364285, 0.008145104, 0.020997444, 0.025889797, 0.0302268, -0.02107678, 0.03720832, -0.009936763, 0.013361409, -0.00080492406, -0.015972868, -0.0035172042, -0.041968442, 0.012369717, 0.020389207, 0.011530083, 0.0016420782, -0.026947603, 0.010465666, 0.009983042, 0.011549917, -0.013923368, -0.0075699226, -0.012442441, 0.0031635005, -0.0003237464, -0.009196299, 0.007920321, -0.003556872, 0.0043105586, 0.036520746, 0.0029155773, -0.0025073302, -0.016224096, 0.0094541395, -0.016409213, 0.01192676, 0.0008702105, 0.014796059, 0.002148668, -0.013414299, -0.026154248, -0.02235937, 0.011801146, 0.012442441, -0.0016685233, 0.008898791, 0.0063931136, -0.01094829, 0.013963036, 0.002611458, -0.015880309, 0.01789014, -0.0050378, -0.0035800114, -0.016885225, 0.0073120827, -0.040117282, 0.005748513, 0.0027536007, -0.022676712, 0.008674008, -0.024699764, 0.0045783157, -0.030676367, 0.0008602936, 0.038742136, 0.010551613, 0.020812329, 0.0017354626, 0.011278854, -0.0068559037, -0.016686887, -0.007424474, 0.0022759351, 0.014452271, 0.0141217075, 0.0020296648, -0.0016784403, -0.017810805, -0.009526864, -0.015906755, -0.012092043, 0.0143597135, -0.009090519, 0.01352008, -0.012620945, -0.008270719, -0.013288685, 0.027978962, -0.0049882154, -0.0044791466, -0.008726898, -0.015946422, -0.02153957, 0.012938287, -0.016753, 0.022531264, 0.015933199, -0.013361409, 0.03834546, -0.001832979, -0.008773177, -0.012111876, -0.02524189, 0.024792323, 0.009758258, 0.029327665, 0.01141108, 0.01022766, -0.016726553, 0.008409556, 0.011424302, 0.023192393, 0.0021354454, -0.01346719, -0.016435657, 0.0051072184, -0.0037485992, -0.015338183, -0.009374804, -0.02251804, -0.026815377, -0.022703156, 0.01582742, 0.016951337, -0.014491939, -0.011523472, -0.018154591, 0.0061418847, -0.00039378472, -0.009599588, 0.00061898166, -0.026088135, -0.010809453, -0.012680447, 0.0011892051, 0.00817155, -0.011060682, -0.007834374, -0.0015015884, 0.018974392, -0.026379032, 0.01794303, -0.029063214, 0.005731985, -0.015721638, 0.013202738, 0.018855387, -0.017043896, 0.021883357, -0.00976487, -0.0063501406, 0.0006817889, -0.021010667, -0.0034411745, -0.019701632, -0.015999312, -0.0065418677, 0.0036130678, -0.015615858, -0.017519908, -0.035330713, 0.029486336, 0.0007094736, -0.015351406, -0.00010252659, -0.0019618992, 0.02565179, 0.0023751045, 0.024382424, -0.007807929, -0.016157983, -0.008012879, -0.0076823146, 0.020256981, -0.0023784102, -0.01125902, -0.017229011, -0.009163243, -0.0073980293, 0.018802498, 0.0007470753, 0.004786571, 0.038133897, 0.022782492, 0.0136721395, 0.0048394613, -0.00033986144, 0.0070608538, 0.005771653, -0.026167471, -0.021394122, -0.0039237984, 0.01922562, 0.03868925, 0.00899796, -0.021658573, -0.010809453, -0.010604503, -0.011966428, 0.0051733316, 0.003074248, 0.017757915, 0.051620923, 0.0036593468, -0.016673664, 0.013024233, 0.004826239, 0.02750295, -0.00817155, -0.012865563, 0.013037456, 0.01758602, -0.0006045195, 0.010187992, -0.03263331, -0.015814196, 0.029274775, 0.0018957863, -0.009672312, 0.0011966428, -0.015748084, -0.0054972842, -0.041386653, 0.012250713, 0.007530255, 0.0047204583, 0.018286817, -0.02134123, 0.0033915897, -0.007391418, -0.0035304269, -0.0032180436, -0.0002681703, -0.009361581, -0.013249017, 0.02036276, -0.010749951, -0.02107678, -0.017242234, -0.01644888, 0.02483199, -0.0060823835, 0.0042576683, 0.020071864, 0.014372936, -0.013963036, -0.008350055, 0.005474145, -0.0029321054, -0.029512782, -0.023046944, -0.017718246, 0.0016106745, -0.021618906, -0.011490415, -0.009209521, 0.009282245, 0.01459772, 0.024567539, -0.0021073474, 0.02168502, 0.0021040419, -0.025770793, 0.0014296906, 0.0042279176, -0.009553309, -0.0041254424, -0.012396161, 0.0018395904, -0.016753, -0.0076889256, -0.0010991263, -0.022782492, 0.004224612, 0.014518384, 0.015100177, -0.01315646, 0.0036362074, 0.19643453, -0.006902183, -0.01223088, 0.0163431, -0.0065352563, 0.018723162, 0.0247791, -0.0050807735, -0.0047832653, -0.009196299, -0.014928284, 0.027529396, 0.0019933027, 0.0026180693, 0.0016205915, -0.01639599, -0.02153957, -0.017202567, -0.024131194, -0.03316221, -0.00085698796, -0.0063600573, -0.03181351, -0.009037628, 0.0032907678, -0.0050378, -0.0010346663, -0.01835293, 0.01361925, 0.026088135, 0.0005751819, -0.016819112, -0.009434305, 0.0023354369, -0.020997444, -0.0067402064, 0.008310387, 0.0040626354, 0.0040890803, 0.030306136, -0.015959645, 0.021037113, -0.0009916929, 0.0070872987, -0.01161603, 0.017096786, -0.001370189, -0.0042080837, 0.0008140146, 0.014108485, -0.02606169, -0.010472277, 0.021261897, 0.019966085, -0.011735033, -0.010908622, 0.0016586065, 0.029697897, -0.01830004, -0.011034236, -0.0038246291, 0.031787064, -0.0079401545, 0.0075500887, -0.009844205, 0.022161031, -0.0044097276, 0.0059600743, 0.011959816, -0.019371068, 0.0037915725, -0.015020842, -0.010968124, -0.0062741106, -0.00012179228, -0.027053382, 0.03377045, 0.005725374, 0.0026891406, -0.0011602807, -0.00403619, -0.0076889256, 0.0040791635, -0.0040989975, -0.018895056, -0.0197413, 0.014756391, 0.0057914867, -0.012296992, -0.017757915, 0.008422779, -0.020137977, 0.003537038, -0.0011040848, 0.0061286623, 0.031734172, -0.011748255, 0.03207796, 0.008204606, -0.0043270867, -0.02652448, -0.03501337, 0.0050609396, 0.015615858, -0.027476504, 0.0026660012, 0.00057104987, 0.022861827, -0.012098653, -0.0024461758, 0.01022766, -0.008350055, 0.0114441365, 0.0022081695, -0.0044130334, 0.018009143, -0.0013867173, -0.016620774, -0.0060460214, -0.01459772, 0.008164939, -0.013249017, 0.005748513, 0.005232833, -0.024950994, -0.011490415, -0.013480413, 0.021552794, 0.011285465, -0.03604473, 0.0041915555, -0.0052096937, 0.013037456, -0.012449052, -0.013037456, 0.01639599, 0.0051997765, -0.002267671, 0.015047288, 0.018643826, 0.013976259, 0.0052394443, 0.0059534633, 0.010016099, -0.0016528215, -0.03670586, 0.023483288, 0.008250885, -0.0051997765, -0.012607723, -0.019133061, -0.005798098, -0.012991177, -0.001120613, 0.015272071, -0.03279198, -0.040646188, -0.014994397, -0.009031017, 0.014108485, -0.011424302, 0.021420566, 0.0053353077, 0.0052361386, -0.012607723, -0.0076823146, -0.17136453, -0.0011024319, 0.011351578, -0.0062278314, 0.008700453, 0.0017106703, 0.011992873, 0.0048758234, -0.004568399, -0.0052460553, 0.02729139, -0.013407689, -0.041809775, 0.0023552708, 0.025612123, 0.031337496, -0.008925236, 0.017004227, 0.013989481, 0.005252667, 0.02344362, 0.023879966, -0.0006917058, 0.013949813, 0.0005198124, 0.0051072184, 0.0040791635, 0.0046576513, -0.012574666, -0.013698584, -0.012654002, -0.00344448, -0.006862515, 0.012944899, 0.023324618, 0.004743598, -0.029724343, 0.006307167, 0.0016453839, 0.0093549695, -0.008469057, 0.035648055, 0.01454483, -0.0115697505, 0.011344967, 0.015496855, -0.013738252, -0.0026610426, -0.005923712, -0.007953377, 0.01609187, -0.02698727, 0.011483804, -0.014796059, 0.024408868, 0.009778093, -0.0014437396, 0.007001352, 0.022068473, -0.011701977, -0.00007365386, -0.023377508, 0.012964732, -0.010445832, -0.018114924, -0.04009084, -0.0056427326, 0.0071269665, -0.03300354, 0.028666537, -0.025850128, -0.017440572, 0.007966599, -0.026484812, 0.012409384, -0.0022032112, -0.009778093, -0.005798098, -0.015430742, -0.0028775623, -0.011629253, 0.035304267, -0.03295065, 0.019384291, -0.009513641, 0.017387683, -0.019873526, -0.011113572, -0.012052375, -0.010531778, 0.010459054, -0.034458023, -0.01876283, -0.00026589766, 0.008217828, 0.025202222, 0.0009792967, -0.005712151, 0.005150192, -0.01794303, -0.0048956573, -0.010895399, -0.007345139, -0.005725374, 0.036917422, -0.009447528, 0.042603128, 0.017969476, 0.03094082, -0.0061617186, 0.01459772, 0.0040031336, 0.004340309, 0.01979419, -0.0055799256, 0.020349538, -0.019040504, -0.019648742, 0.019780967, -0.0012842424, 0.03839835, -0.0005590669, -0.023165947, -0.011067293, 0.014015927, 0.012303604, -0.10461699, -0.009315303, 0.00067393796, 0.021195784, -0.017506685, 0.009427694, 0.0045055915, 0.00096194213, 0.015919978, 0.016435657, -0.014095262, 0.0028676454, -0.004730375, -0.0136721395, 0.010306995, -0.0073186937, -0.013401077, -0.0090045715, -0.019344624, 0.009242578, -0.016686887, 0.0007702148, 0.012528387, -0.012025929, -0.022689935, -0.009976431, -0.032236632, 0.02750295, 0.004158499, 0.01855127, 0.002371799, -0.0053320024, 0.007715371, -0.03252753, -0.013500246, 0.011973039, -0.008469057, -0.0022924636, 0.0213809, -0.04842106, 0.018895056, 0.0015858823, 0.007576534, -0.024964217, 0.014994397, 0.0020412346, -0.005249361, 0.0014792753, 0.009348359, -0.03638852, -0.028402084, -0.01084251, -0.019979307, -0.0035304269, 0.0036064566, -0.014994397, 0.017652133, 0.01305729, 0.007907098, 0.006667482, 0.0028676454, -0.020005751, -0.012991177, 0.03001524, -0.00046609566, 0.015615858, -0.02935411, -0.0009925193, 0.033796895, -0.019040504, -0.014901839, 0.009533474, -0.010121879, 0.026458368, -0.038054563, 0.009956597, -0.0030048296, -0.0019519823, 0.016872002, -0.001142926, -0.014941507, -0.02930122, 0.004611372, -0.029512782, 0.030887928, -0.0018015754, 0.010624337, -0.0044791466, -0.007993045, -0.0056790947, 0.0019602464, 0.011173073, 0.0023222142, -0.00022499033, 0.0024511344, 0.015443964, 0.018987615, -0.02349651, -0.008740121, 0.00029730127, -0.004750209, -0.017969476, -0.06442037, 0.006816236, 0.0019833858, 0.0063038613, -0.0054675336, -0.01161603, 0.032818425, -0.030094575, 0.009685534, -0.0012520123, -0.0013090346, 0.0085285595, 0.015959645, -0.0006574098, -0.00688896, -0.019133061, -0.0008057505, 0.009672312, 0.019913195, 0.008145104, -0.012290381, 0.0016139803, 0.026405476, 0.014875393, -0.002168502, 0.012792839, -0.011840814, 0.003464314, 0.0069682957, -0.0073781954, 0.018842166, -0.03165484, -0.017242234, 0.006789791, -0.009130186, -0.012263936, -0.015258849, 0.0036692638, 0.008865735, 0.0272385, -0.004009745, -0.017612467, 0.022584153, -0.023760963, 0.004231223, 0.004287419, -0.020891665, 0.022425482, 0.007986434, -0.0030345803, 0.010459054, 0.013844033, 0.012283769, -0.027899627, -0.006250971, -0.023430398, 0.0122573245, -0.004128748, 0.013830811, -0.016766222, 0.022861827, -0.011192908, 0.03665297, -0.00212057, -0.009031017, -0.024170863, -0.0010230965, -0.0064393925, 0.014015927, -0.005956769, 0.000146378, -0.008436001, 0.010604503, 0.013169682, -0.00516672, 0.0012321784, -0.022332925, -0.0022643656, -0.03993217, 0.02050821, 0.01577453, -0.0043667546, -0.022372592, -0.001152843, 0.010002876, 0.0036262905, -0.017876917, 0.006406336, -0.009401249, 0.019569406, -0.03033258, -0.01269367, 0.0020412346, 0.009989654, -0.0014627471, 0.04101642, 0.0011189602, -0.023046944, 0.0013230836, 0.024250198, 0.01207882, -0.0062377485, -0.010452444, -0.020825552, 0.006693927, -0.005305557, -0.018339708, -0.041307315, -0.012296992, 0.0070542423, 0.0019371068, 0.0117945345, -0.020032197, 0.017797582, -0.015443964, 0.00537167, -0.00015474542, -0.0117747, -0.011140017, 0.017334793, 0.016250541, 0.006019576, 0.017612467, -0.017982699, 0.010366497, 0.0029949127, 0.015086955, -0.000027813887, -0.008660785, -0.008713675, -0.0050873845, -0.0117945345, -0.016118316, -0.0022015583, 0.006518728, -0.0047766543, 0.0055501745, 0.039747052, -0.034061346, 0.049425974, 0.0023883271, -0.0035601775, 0.00863434, -0.003897353, 0.016237319, 0.006436087, -0.00037828952, -0.017797582, -0.019450404, 0.0009809496, 0.0036461244, 0.013176293, 0.0036461244, -0.01094829, -0.018260373, 0.00035246418, 0.012885396, -0.006796402, -0.015972868, 0.027899627, -0.0077021485, 0.027608732, 0.01696456, -0.0014486981, -0.017969476, 0.015642302, -0.00477996, -0.0048890463, -0.020058641, 0.008323609, 0.013017623, -0.01886861, -0.008204606, 0.016303431, -0.010029321, -0.001018138, -0.0332151, 0.010525168, 0.032871313, 0.011549917, 0.010928456, -0.014253933, -0.011384634, 0.00894507, 0.034616694, -0.016872002, -0.010987958, -0.011953205], 35 'numCandidates': 150, 36 'limit': 10 37 } 38 }, { 39 '$project': { 40 '_id': 0, 41 'title': 1, 42 'plot': 1, 43 'year': 1, 44 'score': { 45 '$meta': 'vectorSearchScore' 46 } 47 } 48 } 49 ]; 50 // run pipeline 51 const result = coll.aggregate(agg); 52 53 // print results 54 await result.forEach((doc) => console.dir(JSON.stringify(doc))); 55 } finally { 56 await client.close(); 57 } 58 } 59 run().catch(console.dir);
1 '{"plot":"In this magical tale about the boy who refuses to grow up, Peter Pan and his mischievous fairy sidekick Tinkerbell visit the nursery of Wendy, Michael, and John Darling. With a sprinkling ...","title":"Peter Pan","year":1960,"score":0.748110830783844}' 2 '{"plot":"A down-on-his-luck inventor turns a broken-down Grand Prix car into a fancy vehicle for his children, and then they go off on a magical fantasy adventure to save their grandfather in a far-off land.","title":"Chitty Chitty Bang Bang","year":1968,"score":0.7442465424537659}' 3 '{"plot":"A young man comes to the rescue of his girlfriend abducted by thieves and brought to Rio. An extravagant adventure ensues.","title":"That Man from Rio","year":1964,"score":0.7416020035743713}' 4 '{"plot":"A boy raised by wolves tries to adapt to human village life.","title":"Jungle Book","year":1942,"score":0.7387760877609253}' 5 '{"plot":"A pilot, stranded in the desert, meets a little boy who is a prince on a planet.","title":"The Little Prince","year":1974,"score":0.7378944158554077}' 6 '{"plot":"A red balloon with a life of its own follows a little boy around the streets of Paris.","title":"The Red Balloon","year":1956,"score":0.7342712879180908}' 7 '{"plot":"A poor boy wins the opportunity to tour the most eccentric and wonderful candy factory of all.","title":"Willy Wonka & the Chocolate Factory","year":1971,"score":0.7342107892036438}' 8 '{"plot":"An apprentice witch, three kids and a cynical conman search for the missing component to a magic spell useful to the defense of Britain.","title":"Bedknobs and Broomsticks","year":1971,"score":0.7339356541633606}' 9 '{"plot":"Arriving home to find his native land under the yoke of corrupt merchants, an adventurer named Sadko sets sail in search of a mythical bird of happiness.","title":"Sadko","year":1953,"score":0.7339220643043518}' 10 `{"plot":"A young boys' coming of age tale set in a strange, carnivalesque village becomes the recreation of a memory that the director has twenty years later.","title":"Pastoral Hide and Seek","year":1974,"score":0.733299970626831}`
Atlas Vector Search filters the documents based on the year
field value that
ranges between 1955 and 1975. It returns documents that summarize
children's adventures in the plot for movies released between 1955 and
1975.
Tip
See also: Additional Filter Examples
The How to Perform Semantic Search Against Data in Your Atlas Cluster tutorial demonstrates other
pre-filters in semantic search queries against the embedded data in
the sample_mflix.embedded_movies
collection.
The following query uses the $vectorSearch
stage to search
the plot_embedding
field using vector embeddings for the string
time travel. It considers up to 150
nearest neighbors, and
returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include only theplot
andtitle
fields in the results.Add a field named
score
that shows the vector search score for each document in the results.
1 import pymongo 2 import datetime 3 4 # connect to your Atlas cluster 5 client = pymongo.MongoClient("<connection-string>") 6 7 # define pipeline 8 pipeline = [ 9 { 10 '$vectorSearch': { 11 'index': 'vector_index', 12 'path': 'plot_embedding', 13 'queryVector': [-0.0016261312, -0.028070757, -0.011342932, -0.012775794, -0.0027440966, 0.008683807, -0.02575152, -0.02020668, -0.010283281, -0.0041719596, 0.021392956, 0.028657231, -0.006634482, 0.007490867, 0.018593878, 0.0038187427, 0.029590257, -0.01451522, 0.016061379, 0.00008528442, -0.008943722, 0.01627464, 0.024311995, -0.025911469, 0.00022596726, -0.008863748, 0.008823762, -0.034921836, 0.007910728, -0.01515501, 0.035801545, -0.0035688248, -0.020299982, -0.03145631, -0.032256044, -0.028763862, -0.0071576433, -0.012769129, 0.012322609, -0.006621153, 0.010583182, 0.024085402, -0.001623632, 0.007864078, -0.021406285, 0.002554159, 0.012229307, -0.011762793, 0.0051682983, 0.0048484034, 0.018087378, 0.024325324, -0.037694257, -0.026537929, -0.008803768, -0.017767483, -0.012642504, -0.0062712682, 0.0009771782, -0.010409906, 0.017754154, -0.004671795, -0.030469967, 0.008477209, -0.005218282, -0.0058480743, -0.020153364, -0.0032805866, 0.004248601, 0.0051449724, 0.006791097, 0.007650814, 0.003458861, -0.0031223053, -0.01932697, -0.033615597, 0.00745088, 0.006321252, -0.0038154104, 0.014555207, 0.027697546, -0.02828402, 0.0066711367, 0.0077107945, 0.01794076, 0.011349596, -0.0052715978, 0.014755142, -0.019753495, -0.011156326, 0.011202978, 0.022126047, 0.00846388, 0.030549942, -0.0041386373, 0.018847128, -0.00033655585, 0.024925126, -0.003555496, -0.019300312, 0.010749794, 0.0075308536, -0.018287312, -0.016567878, -0.012869096, -0.015528221, 0.0078107617, -0.011156326, 0.013522214, -0.020646535, -0.01211601, 0.055928253, 0.011596181, -0.017247654, 0.0005939711, -0.026977783, -0.003942035, -0.009583511, -0.0055248477, -0.028737204, 0.023179034, 0.003995351, 0.0219661, -0.008470545, 0.023392297, 0.010469886, -0.015874773, 0.007890735, -0.009690142, -0.00024970944, 0.012775794, 0.0114762215, 0.013422247, 0.010429899, -0.03686786, -0.006717788, -0.027484283, 0.011556195, -0.036068123, -0.013915418, -0.0016327957, 0.0151016945, -0.020473259, 0.004671795, -0.012555866, 0.0209531, 0.01982014, 0.024485271, 0.0105431955, -0.005178295, 0.033162415, -0.013795458, 0.007150979, 0.010243294, 0.005644808, 0.017260984, -0.0045618312, 0.0024725192, 0.004305249, -0.008197301, 0.0014203656, 0.0018460588, 0.005015015, -0.011142998, 0.01439526, 0.022965772, 0.02552493, 0.007757446, -0.0019726837, 0.009503538, -0.032042783, 0.008403899, -0.04609149, 0.013808787, 0.011749465, 0.036388017, 0.016314628, 0.021939443, -0.0250051, -0.017354285, -0.012962398, 0.00006107364, 0.019113706, 0.03081652, -0.018114036, -0.0084572155, 0.009643491, -0.0034721901, 0.0072642746, -0.0090636825, 0.01642126, 0.013428912, 0.027724205, 0.0071243206, -0.6858542, -0.031029783, -0.014595194, -0.011449563, 0.017514233, 0.01743426, 0.009950057, 0.0029706885, -0.015714826, -0.001806072, 0.011856096, 0.026444625, -0.0010663156, -0.006474535, 0.0016161345, -0.020313311, 0.0148351155, -0.0018393943, 0.0057347785, 0.018300641, -0.018647194, 0.03345565, -0.008070676, 0.0071443142, 0.014301958, 0.0044818576, 0.003838736, -0.007350913, -0.024525259, -0.001142124, -0.018620536, 0.017247654, 0.007037683, 0.010236629, 0.06046009, 0.0138887605, -0.012122675, 0.037694257, 0.0055081863, 0.042492677, 0.00021784494, -0.011656162, 0.010276617, 0.022325981, 0.005984696, -0.009496873, 0.013382261, -0.0010563189, 0.0026507939, -0.041639622, 0.008637156, 0.026471283, -0.008403899, 0.024858482, -0.00066686375, -0.0016252982, 0.027590916, 0.0051449724, 0.0058647357, -0.008743787, -0.014968405, 0.027724205, -0.011596181, 0.0047650975, -0.015381602, 0.0043718936, 0.002159289, 0.035908177, -0.008243952, -0.030443309, 0.027564257, 0.042625964, -0.0033688906, 0.01843393, 0.019087048, 0.024578573, 0.03268257, -0.015608194, -0.014128681, -0.0033538956, -0.0028757197, -0.004121976, -0.032389335, 0.0034322033, 0.058807302, 0.010943064, -0.030523283, 0.008903735, 0.017500903, 0.00871713, -0.0029406983, 0.013995391, -0.03132302, -0.019660193, -0.00770413, -0.0038853872, 0.0015894766, -0.0015294964, -0.006251275, -0.021099718, -0.010256623, -0.008863748, 0.028550599, 0.02020668, -0.0012962399, -0.003415542, -0.0022509254, 0.0119360695, 0.027590916, -0.046971202, -0.0015194997, -0.022405956, 0.0016677842, -0.00018535563, -0.015421589, -0.031802863, 0.03814744, 0.0065411795, 0.016567878, -0.015621523, 0.022899127, -0.011076353, 0.02841731, -0.002679118, -0.002342562, 0.015341615, 0.01804739, -0.020566562, -0.012989056, -0.002990682, 0.01643459, 0.00042527664, 0.008243952, -0.013715484, -0.004835075, -0.009803439, 0.03129636, -0.021432944, 0.0012087687, -0.015741484, -0.0052016205, 0.00080890034, -0.01755422, 0.004811749, -0.017967418, -0.026684547, -0.014128681, 0.0041386373, -0.013742141, -0.010056688, -0.013268964, -0.0110630235, -0.028337335, 0.015981404, -0.00997005, -0.02424535, -0.013968734, -0.028310679, -0.027750863, -0.020699851, 0.02235264, 0.001057985, 0.00081639783, -0.0099367285, 0.013522214, -0.012016043, -0.00086471526, 0.013568865, 0.0019376953, -0.019020405, 0.017460918, -0.023045745, 0.008503866, 0.0064678704, -0.011509543, 0.018727167, -0.003372223, -0.0028690554, -0.0027024434, -0.011902748, -0.012182655, -0.015714826, -0.0098634185, 0.00593138, 0.018753825, 0.0010146659, 0.013029044, 0.0003521757, -0.017620865, 0.04102649, 0.00552818, 0.024485271, -0.009630162, -0.015608194, 0.0006718621, -0.0008418062, 0.012395918, 0.0057980907, 0.016221326, 0.010616505, 0.004838407, -0.012402583, 0.019900113, -0.0034521967, 0.000247002, -0.03153628, 0.0011038032, -0.020819811, 0.016234655, -0.00330058, -0.0032289368, 0.00078973995, -0.021952773, -0.022459272, 0.03118973, 0.03673457, -0.021472929, 0.0072109587, -0.015075036, 0.004855068, -0.0008151483, 0.0069643734, 0.010023367, -0.010276617, -0.023019087, 0.0068244194, -0.0012520878, -0.0015086699, 0.022046074, -0.034148756, -0.0022192693, 0.002427534, -0.0027124402, 0.0060346797, 0.015461575, 0.0137554705, 0.009230294, -0.009583511, 0.032629255, 0.015994733, -0.019167023, -0.009203636, 0.03393549, -0.017274313, -0.012042701, -0.0009930064, 0.026777849, -0.013582194, -0.0027590916, -0.017594207, -0.026804507, -0.0014236979, -0.022032745, 0.0091236625, -0.0042419364, -0.00858384, -0.0033905501, -0.020739838, 0.016821127, 0.022539245, 0.015381602, 0.015141681, 0.028817179, -0.019726837, -0.0051283115, -0.011489551, -0.013208984, -0.0047017853, -0.0072309524, 0.01767418, 0.0025658219, -0.010323267, 0.012609182, -0.028097415, 0.026871152, -0.010276617, 0.021912785, 0.0022542577, 0.005124979, -0.0019710176, 0.004518512, -0.040360045, 0.010969722, -0.0031539614, -0.020366628, -0.025778178, -0.0110030435, -0.016221326, 0.0036587953, 0.016207997, 0.003007343, -0.0032555948, 0.0044052163, -0.022046074, -0.0008822095, -0.009363583, 0.028230704, -0.024538586, 0.0029840174, 0.0016044717, -0.014181997, 0.031349678, -0.014381931, -0.027750863, 0.02613806, 0.0004136138, -0.005748107, -0.01868718, -0.0010138329, 0.0054348772, 0.010703143, -0.003682121, 0.0030856507, -0.004275259, -0.010403241, 0.021113047, -0.022685863, -0.023032416, 0.031429652, 0.001792743, -0.005644808, -0.011842767, -0.04078657, -0.0026874484, 0.06915057, -0.00056939584, -0.013995391, 0.010703143, -0.013728813, -0.022939114, -0.015261642, -0.022485929, 0.016807798, 0.007964044, 0.0144219175, 0.016821127, 0.0076241563, 0.005461535, -0.013248971, 0.015301628, 0.0085171955, -0.004318578, 0.011136333, -0.0059047225, -0.010249958, -0.018207338, 0.024645219, 0.021752838, 0.0007614159, -0.013648839, 0.01111634, -0.010503208, -0.0038487327, -0.008203966, -0.00397869, 0.0029740208, 0.008530525, 0.005261601, 0.01642126, -0.0038753906, -0.013222313, 0.026537929, 0.024671877, -0.043505676, 0.014195326, 0.024778508, 0.0056914594, -0.025951454, 0.017620865, -0.0021359634, 0.008643821, 0.021299653, 0.0041686273, -0.009017031, 0.04044002, 0.024378639, -0.027777521, -0.014208655, 0.0028623908, 0.042119466, 0.005801423, -0.028124074, -0.03129636, 0.022139376, -0.022179363, -0.04067994, 0.013688826, 0.013328944, 0.0046184794, -0.02828402, -0.0063412455, -0.0046184794, -0.011756129, -0.010383247, -0.0018543894, -0.0018593877, -0.00052024535, 0.004815081, 0.014781799, 0.018007403, 0.01306903, -0.020433271, 0.009043689, 0.033189073, -0.006844413, -0.019766824, -0.018767154, 0.00533491, -0.0024575242, 0.018727167, 0.0058080875, -0.013835444, 0.0040719924, 0.004881726, 0.012029372, 0.005664801, 0.03193615, 0.0058047553, 0.002695779, 0.009290274, 0.02361889, 0.017834127, 0.0049017193, -0.0036388019, 0.010776452, -0.019793482, 0.0067777685, -0.014208655, -0.024911797, 0.002385881, 0.0034988478, 0.020899786, -0.0025858153, -0.011849431, 0.033189073, -0.021312982, 0.024965113, -0.014635181, 0.014048708, -0.0035921505, -0.003347231, 0.030869836, -0.0017161017, -0.0061346465, 0.009203636, -0.025165047, 0.0068510775, 0.021499587, 0.013782129, -0.0024475274, -0.0051149824, -0.024445284, 0.006167969, 0.0068844, -0.00076183246, 0.030150073, -0.0055948244, -0.011162991, -0.02057989, -0.009703471, -0.020646535, 0.008004031, 0.0066378145, -0.019900113, -0.012169327, -0.01439526, 0.0044252095, -0.004018677, 0.014621852, -0.025085073, -0.013715484, -0.017980747, 0.0071043274, 0.011456228, -0.01010334, -0.0035321703, -0.03801415, -0.012036037, -0.0028990454, -0.05419549, -0.024058744, -0.024272008, 0.015221654, 0.027964126, 0.03182952, -0.015354944, 0.004855068, 0.011522872, 0.004771762, 0.0027874154, 0.023405626, 0.0004242353, -0.03132302, 0.007057676, 0.008763781, -0.0027057757, 0.023005757, -0.0071176565, -0.005238275, 0.029110415, -0.010989714, 0.013728813, -0.009630162, -0.029137073, -0.0049317093, -0.0008630492, -0.015248313, 0.0043219104, -0.0055681667, -0.013175662, 0.029723546, 0.025098402, 0.012849103, -0.0009996708, 0.03118973, -0.0021709518, 0.0260181, -0.020526575, 0.028097415, -0.016141351, 0.010509873, -0.022965772, 0.002865723, 0.0020493253, 0.0020509914, -0.0041419696, -0.00039695262, 0.017287642, 0.0038987163, 0.014795128, -0.014661839, -0.008950386, 0.004431874, -0.009383577, 0.0012604183, -0.023019087, 0.0029273694, -0.033135757, 0.009176978, -0.011023037, -0.002102641, 0.02663123, -0.03849399, -0.0044152127, 0.0004527676, -0.0026924468, 0.02828402, 0.017727496, 0.035135098, 0.02728435, -0.005348239, -0.001467017, -0.019766824, 0.014715155, 0.011982721, 0.0045651635, 0.023458943, -0.0010046692, -0.0031373003, -0.0006972704, 0.0019043729, -0.018967088, -0.024311995, 0.0011546199, 0.007977373, -0.004755101, -0.010016702, -0.02780418, -0.004688456, 0.013022379, -0.005484861, 0.0017227661, -0.015394931, -0.028763862, -0.026684547, 0.0030589928, -0.018513903, 0.028363993, 0.0044818576, -0.009270281, 0.038920518, -0.016008062, 0.0093902415, 0.004815081, -0.021059733, 0.01451522, -0.0051583014, 0.023765508, -0.017874114, -0.016821127, -0.012522544, -0.0028390652, 0.0040886537, 0.020259995, -0.031216389, -0.014115352, -0.009176978, 0.010303274, 0.020313311, 0.0064112223, -0.02235264, -0.022872468, 0.0052449396, 0.0005723116, 0.0037321046, 0.016807798, -0.018527232, -0.009303603, 0.0024858483, -0.0012662497, -0.007110992, 0.011976057, -0.007790768, -0.042999174, -0.006727785, -0.011829439, 0.007024354, 0.005278262, -0.017740825, -0.0041519664, 0.0085905045, 0.027750863, -0.038387362, 0.024391968, 0.00087721116, 0.010509873, -0.00038508154, -0.006857742, 0.0183273, -0.0037054466, 0.015461575, 0.0017394272, -0.0017944091, 0.014181997, -0.0052682655, 0.009023695, 0.00719763, -0.013522214, 0.0034422, 0.014941746, -0.0016711164, -0.025298337, -0.017634194, 0.0058714002, -0.005321581, 0.017834127, 0.0110630235, -0.03369557, 0.029190388, -0.008943722, 0.009363583, -0.0034222065, -0.026111402, -0.007037683, -0.006561173, 0.02473852, -0.007084334, -0.010110005, -0.008577175, 0.0030439978, -0.022712521, 0.0054582027, -0.0012620845, -0.0011954397, -0.015741484, 0.0129557345, -0.00042111133, 0.00846388, 0.008930393, 0.016487904, 0.010469886, -0.007917393, -0.011762793, -0.0214596, 0.000917198, 0.021672864, 0.010269952, -0.007737452, -0.010243294, -0.0067244526, -0.015488233, -0.021552904, 0.017127695, 0.011109675, 0.038067464, 0.00871713, -0.0025591573, 0.021312982, -0.006237946, 0.034628596, -0.0045251767, 0.008357248, 0.020686522, 0.0010696478, 0.0076708077, 0.03772091, -0.018700508, -0.0020676525, -0.008923728, -0.023298996, 0.018233996, -0.010256623, 0.0017860786, 0.009796774, -0.00897038, -0.01269582, -0.018527232, 0.009190307, -0.02372552, -0.042119466, 0.008097334, -0.0066778013, -0.021046404, 0.0019593548, 0.011083017, -0.0016028056, 0.012662497, -0.000059095124, 0.0071043274, -0.014675168, 0.024831824, -0.053582355, 0.038387362, 0.0005698124, 0.015954746, 0.021552904, 0.031589597, -0.009230294, -0.0006147976, 0.002625802, -0.011749465, -0.034362018, -0.0067844326, -0.018793812, 0.011442899, -0.008743787, 0.017474247, -0.021619547, 0.01831397, -0.009037024, -0.0057247817, -0.02728435, 0.010363255, 0.034415334, -0.024032086, -0.0020126705, -0.0045518344, -0.019353628, -0.018340627, -0.03129636, -0.0034038792, -0.006321252, -0.0016161345, 0.033642255, -0.000056075285, -0.005005019, 0.004571828, -0.0024075406, -0.00010215386, 0.0098634185, 0.1980148, -0.003825407, -0.025191706, 0.035161756, 0.005358236, 0.025111731, 0.023485601, 0.0023342315, -0.011882754, 0.018287312, -0.0068910643, 0.003912045, 0.009243623, -0.001355387, -0.028603915, -0.012802451, -0.030150073, -0.014795128, -0.028630573, -0.0013487226, 0.002667455, 0.00985009, -0.0033972147, -0.021486258, 0.009503538, -0.017847456, 0.013062365, -0.014341944, 0.005078328, 0.025165047, -0.015594865, -0.025924796, -0.0018177348, 0.010996379, -0.02993681, 0.007324255, 0.014475234, -0.028577257, 0.005494857, 0.00011725306, -0.013315615, 0.015941417, 0.009376912, 0.0025158382, 0.008743787, 0.023832154, -0.008084005, -0.014195326, -0.008823762, 0.0033455652, -0.032362677, -0.021552904, -0.0056081535, 0.023298996, -0.025444955, 0.0097301295, 0.009736794, 0.015274971, -0.0012937407, -0.018087378, -0.0039387033, 0.008637156, -0.011189649, -0.00023846315, -0.011582852, 0.0066411467, -0.018220667, 0.0060846633, 0.0376676, -0.002709108, 0.0072776037, 0.0034188742, -0.010249958, -0.0007747449, -0.00795738, -0.022192692, 0.03910712, 0.032122757, 0.023898797, 0.0076241563, -0.007397564, -0.003655463, 0.011442899, -0.014115352, -0.00505167, -0.031163072, 0.030336678, -0.006857742, -0.022259338, 0.004048667, 0.02072651, 0.0030156737, -0.0042119464, 0.00041861215, -0.005731446, 0.011103011, 0.013822115, 0.021512916, 0.009216965, -0.006537847, -0.027057758, -0.04054665, 0.010403241, -0.0056281467, -0.005701456, -0.002709108, -0.00745088, -0.0024841821, 0.009356919, -0.022659205, 0.004061996, -0.013175662, 0.017074378, -0.006141311, -0.014541878, 0.02993681, -0.00028448965, -0.025271678, 0.011689484, -0.014528549, 0.004398552, -0.017274313, 0.0045751603, 0.012455898, 0.004121976, -0.025458284, -0.006744446, 0.011822774, -0.015035049, -0.03257594, 0.014675168, -0.0039187097, 0.019726837, -0.0047251107, 0.0022825818, 0.011829439, 0.005391558, -0.016781142, -0.0058747325, 0.010309938, -0.013049036, 0.01186276, -0.0011246296, 0.0062112883, 0.0028190718, -0.021739509, 0.009883412, -0.0073175905, -0.012715813, -0.017181009, -0.016607866, -0.042492677, -0.0014478565, -0.01794076, 0.012302616, -0.015194997, -0.04433207, -0.020606548, 0.009696807, 0.010303274, -0.01694109, -0.004018677, 0.019353628, -0.001991011, 0.000058938927, 0.010536531, -0.17274313, 0.010143327, 0.014235313, -0.024152048, 0.025684876, -0.0012504216, 0.036601283, -0.003698782, 0.0007310093, 0.004165295, -0.0029157067, 0.017101036, -0.046891227, -0.017460918, 0.022965772, 0.020233337, -0.024072073, 0.017220996, 0.009370248, 0.0010363255, 0.0194336, -0.019606877, 0.01818068, -0.020819811, 0.007410893, 0.0019326969, 0.017887443, 0.006651143, 0.00067394477, -0.011889419, -0.025058415, -0.008543854, 0.021579562, 0.0047484366, 0.014062037, 0.0075508473, -0.009510202, -0.009143656, 0.0046817916, 0.013982063, -0.0027990784, 0.011782787, 0.014541878, -0.015701497, -0.029350337, 0.021979429, 0.01332228, -0.026244693, -0.0123492675, -0.003895384, 0.0071576433, -0.035454992, -0.00046984528, 0.0033522295, 0.039347045, 0.0005119148, 0.00476843, -0.012995721, 0.0024042083, -0.006931051, -0.014461905, -0.0127558, 0.0034555288, -0.0074842023, -0.030256703, -0.007057676, -0.00807734, 0.007804097, -0.006957709, 0.017181009, -0.034575284, -0.008603834, -0.005008351, -0.015834786, 0.02943031, 0.016861115, -0.0050849924, 0.014235313, 0.0051449724, 0.0025924798, -0.0025741523, 0.04289254, -0.002104307, 0.012969063, -0.008310596, 0.00423194, 0.0074975314, 0.0018810473, -0.014248641, -0.024725191, 0.0151016945, -0.017527562, 0.0018727167, 0.0002830318, 0.015168339, 0.0144219175, -0.004048667, -0.004358565, 0.011836103, -0.010343261, -0.005911387, 0.0022825818, 0.0073175905, 0.00403867, 0.013188991, 0.03334902, 0.006111321, 0.008597169, 0.030123414, -0.015474904, 0.0017877447, -0.024551915, 0.013155668, 0.023525586, -0.0255116, 0.017220996, 0.004358565, -0.00934359, 0.0099967085, 0.011162991, 0.03092315, -0.021046404, -0.015514892, 0.0011946067, -0.01816735, 0.010876419, -0.10124666, -0.03550831, 0.0056348112, 0.013942076, 0.005951374, 0.020419942, -0.006857742, -0.020873128, -0.021259667, 0.0137554705, 0.0057880944, -0.029163731, -0.018767154, -0.021392956, 0.030896494, -0.005494857, -0.0027307675, -0.006801094, -0.014821786, 0.021392956, -0.0018110704, -0.0018843795, -0.012362596, -0.0072176233, -0.017194338, -0.018713837, -0.024272008, 0.03801415, 0.00015880188, 0.0044951867, -0.028630573, -0.0014070367, -0.00916365, -0.026537929, -0.009576847, -0.013995391, -0.0077107945, 0.0050016865, 0.00578143, -0.04467862, 0.008363913, 0.010136662, -0.0006268769, -0.006591163, 0.015341615, -0.027377652, -0.00093136, 0.029243704, -0.020886457, -0.01041657, -0.02424535, 0.005291591, -0.02980352, -0.009190307, 0.019460259, -0.0041286405, 0.004801752, 0.0011787785, -0.001257086, -0.011216307, -0.013395589, 0.00088137644, -0.0051616337, 0.03876057, -0.0033455652, 0.00075850025, -0.006951045, -0.0062112883, 0.018140694, -0.006351242, -0.008263946, 0.018154023, -0.012189319, 0.0075508473, -0.044358727, -0.0040153447, 0.0093302615, -0.010636497, 0.032789204, -0.005264933, -0.014235313, -0.018393943, 0.007297597, -0.016114693, 0.015021721, 0.020033404, 0.0137688, 0.0011046362, 0.010616505, -0.0039453674, 0.012109346, 0.021099718, -0.0072842683, -0.019153694, -0.003768759, 0.039320387, -0.006747778, -0.0016852784, 0.018154023, 0.0010963057, -0.015035049, -0.021033075, -0.04345236, 0.017287642, 0.016341286, -0.008610498, 0.00236922, 0.009290274, 0.028950468, -0.014475234, -0.0035654926, 0.015434918, -0.03372223, 0.004501851, -0.012929076, -0.008483873, -0.0044685286, -0.0102233, 0.01615468, 0.0022792495, 0.010876419, -0.0059647025, 0.01895376, -0.0069976957, -0.0042952523, 0.017207667, -0.00036133936, 0.0085905045, 0.008084005, 0.03129636, -0.016994404, -0.014915089, 0.020100048, -0.012009379, -0.006684466, 0.01306903, 0.00015765642, -0.00530492, 0.0005277429, 0.015421589, 0.015528221, 0.032202728, -0.003485519, -0.0014286962, 0.033908837, 0.001367883, 0.010509873, 0.025271678, -0.020993087, 0.019846799, 0.006897729, -0.010216636, -0.00725761, 0.01818068, -0.028443968, -0.011242964, -0.014435247, -0.013688826, 0.006101324, -0.0022509254, 0.013848773, -0.0019077052, 0.017181009, 0.03422873, 0.005324913, -0.0035188415, 0.014128681, -0.004898387, 0.005038341, 0.0012320944, -0.005561502, -0.017847456, 0.0008538855, -0.0047884234, 0.011849431, 0.015421589, -0.013942076, 0.0029790192, -0.013702155, 0.0001199605, -0.024431955, 0.019926772, 0.022179363, -0.016487904, -0.03964028, 0.0050849924, 0.017487574, 0.022792496, 0.0012504216, 0.004048667, -0.00997005, 0.0076041627, -0.014328616, -0.020259995, 0.0005598157, -0.010469886, 0.0016852784, 0.01716768, -0.008990373, -0.001987679, 0.026417969, 0.023792166, 0.0046917885, -0.0071909656, -0.00032051947, -0.023259008, -0.009170313, 0.02071318, -0.03156294, -0.030869836, -0.006324584, 0.013795458, -0.00047151142, 0.016874444, 0.00947688, 0.00985009, -0.029883493, 0.024205362, -0.013522214, -0.015075036, -0.030603256, 0.029270362, 0.010503208, 0.021539574, 0.01743426, -0.023898797, 0.022019416, -0.0068777353, 0.027857494, -0.021259667, 0.0025758184, 0.006197959, 0.006447877, -0.00025200035, -0.004941706, -0.021246338, -0.005504854, -0.008390571, -0.0097301295, 0.027244363, -0.04446536, 0.05216949, 0.010243294, -0.016008062, 0.0122493, -0.0199401, 0.009077012, 0.019753495, 0.006431216, -0.037960835, -0.027377652, 0.016381273, -0.0038620618, 0.022512587, -0.010996379, -0.0015211658, -0.0102233, 0.007071005, 0.008230623, -0.009490209, -0.010083347, 0.024431955, 0.002427534, 0.02828402, 0.0035721571, -0.022192692, -0.011882754, 0.010056688, 0.0011904413, -0.01426197, -0.017500903, -0.00010985966, 0.005591492, -0.0077707744, -0.012049366, 0.011869425, 0.00858384, -0.024698535, -0.030283362, 0.020140035, 0.011949399, -0.013968734, 0.042732596, -0.011649498, -0.011982721, -0.016967745, -0.0060913274, -0.007130985, -0.013109017, -0.009710136], 14 'numCandidates': 150, 15 'limit': 10 16 } 17 }, { 18 '$project': { 19 '_id': 0, 20 'plot': 1, 21 'title': 1, 22 'score': { 23 '$meta': 'vectorSearchScore' 24 } 25 } 26 } 27 ] 28 29 # run pipeline 30 result = client["sample_mflix"]["embedded_movies"].aggregate(pipeline) 31 32 # print results 33 for i in result: 34 print(i) 35
1 {'plot': 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.', 'title': 'Thrill Seekers', 'score': 0.7892671227455139} 2 {'plot': 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.', 'title': 'About Time', 'score': 0.7843604683876038} 3 {'plot': 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.', 'title': 'The Time Machine', 'score': 0.7801066637039185} 4 {'plot': "After using his mother's newly built time machine, Dolf gets stuck involuntary in the year 1212. He ends up in a children's crusade where he confronts his new friends with modern techniques...", 'title': 'Crusade in Jeans', 'score': 0.7789170742034912} 5 {'plot': 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.', 'title': 'Timecop', 'score': 0.7771612405776978} 6 {'plot': 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...', 'title': 'A.P.E.X.', 'score': 0.7730885744094849} 7 {'plot': "Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.", 'title': 'Men in Black 3', 'score': 0.7712380886077881} 8 {'plot': 'Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.', 'title': 'Tomorrowland', 'score': 0.7669923901557922} 9 {'plot': 'With the help of his uncle, a man travels to the future to try and bring his girlfriend back to life.', 'title': 'Love Story 2050', 'score': 0.7649372816085815} 10 {'plot': 'A dimension-traveling wizard gets stuck in the 21st century because cell-phone radiation interferes with his magic. With his home world on the brink of war, he seeks help from a jaded ...', 'title': 'The Portal', 'score': 0.7640786170959473}
The following query filters the documents for movies released between
January 01, 1955
and January 01, 1975
before performing the
semantic search against the sample vector data. It uses the
$and
operator to perform a logical AND
operation of the
specified dates. It then searches the plot_embedding
field in the
filtered documents for 150
nearest neighbors using the vector
embeddings for the string kids adventure, and returns 10
documents in the results. The query also specifies a
$project
stage to do the following:
Exclude the
_id
field and include onlyplot
,title
, andyear
fields in the results.Add a field named
score
that shows the vector search score of the documents in the results.
1 import pymongo 2 import datetime 3 4 # connect to your Atlas cluster 5 client = pymongo.MongoClient("<connection-string>") 6 7 # define pipeline 8 pipeline = [ 9 { 10 '$vectorSearch': { 11 'index': 'vector_index', 12 'path': 'plot_embedding', 13 'filter': { 14 '$and': [ 15 { 16 'year': { 17 '$gt': 1955 18 }, 19 'year': { 20 '$lt': 1975 21 } 22 } 23 ] 24 }, 25 'queryVector': [0.02421053, -0.022372592, -0.006231137, -0.02168502, -0.020375984, 0.037552103, -0.010505334, -0.027026938, 0.0070674648, -0.020032197, 0.01783725, 0.016303431, 0.014584498, -0.018736385, 0.009031017, -0.0045981496, 0.02750295, -0.028322749, 0.010624337, -0.024236975, -0.0048659067, 0.015153068, -0.000490888, -0.022161031, -0.0024560927, -0.007411252, 0.009745035, -0.01886861, 0.02112967, -0.011939983, 0.015153068, 0.0025800543, 0.017824028, -0.02410475, -0.016633997, -0.0018214093, -0.008323609, -0.009222744, 0.009388026, -0.0028296304, 0.0017536436, 0.0065517845, -0.011635863, -0.028454976, -0.018934723, 0.012951509, -0.0032015154, -0.005880739, -0.03115238, 0.012951509, 0.0057749585, 0.009202911, -0.0069352393, 0.00205611, 0.0063732797, 0.0039700773, -0.007100521, -0.0077087595, 0.011596196, -0.010207825, -0.007100521, -0.0051006074, -0.01670011, 0.012773004, -0.035304267, -0.0074971984, 0.0025800543, -0.006118745, 0.030253245, -0.0010751605, 0.039456155, 0.007821151, -0.0017189344, -0.0010801188, 0.0062575825, -0.011490415, -0.022637043, 0.004743598, -0.012601111, 0.0197413, -0.0015255542, -0.025942687, -0.03284487, 0.020389207, 0.009797926, 0.0141217075, -0.0015172901, 0.025982354, -0.011589585, -0.001138794, 0.0006131968, 0.016832335, 0.017916586, 0.014412603, -0.0027155858, 0.011854036, -0.02169824, 0.02112967, -0.020680103, -0.007391418, -0.012872174, 0.021473458, 0.0047766543, -0.0048394613, -0.024395647, 0.0065418677, 0.009797926, -0.00449898, 0.041836217, 0.0023833686, -0.021737909, 0.0136721395, 0.014148152, -0.028772317, -0.027899627, -0.015695194, -0.012521776, 0.02205525, -0.01927851, -0.022068473, 0.020971, 0.02317917, 0.030544141, -0.011827591, 0.0075170323, 0.023086611, -0.02164535, -0.01732157, 0.007510421, -0.027635176, 0.016263764, -0.0008801275, 0.033109322, -0.014505162, -0.029909458, 0.036679417, 0.0074971984, 0.0059137954, -0.031178825, -0.012634167, 0.008416167, 0.030491251, -0.016832335, -0.009507029, 0.010016099, 0.009778093, 0.007840985, 0.010928456, -0.009685534, -0.027661622, 0.024752656, -0.024871659, 0.01516629, 0.002778393, 0.0059501575, 0.022042029, 0.0005441915, 0.0076889256, -0.009883873, -0.019966085, 0.008508725, 0.0098045375, 0.0091169635, -0.02750295, 0.012501942, 0.03480181, 0.021751132, 0.020746216, 0.003546955, -0.014690278, 0.010445832, 0.008469057, -0.00007535833, 0.0059600743, -0.013526691, 0.029539226, -0.011126795, 0.025400562, -0.025466675, -0.0046080663, -0.013923368, -0.009011183, 0.019318178, 0.019053727, -0.012085431, -0.0074707535, 0.0013024234, 0.0076624807, 0.0060460214, -0.0023007276, 0.017757915, 0.031258162, 0.0008768218, -0.003695709, -0.6981518, -0.012058986, 0.008931847, -0.02914255, 0.00833022, 0.028349195, 0.013857256, 0.0029668147, -0.008164939, -0.001494977, -0.0011197866, 0.0104855, 0.014610942, -0.0066608707, 0.000643774, 0.0020676798, 0.008607894, -0.023787407, 0.020494986, 0.015443964, -0.019833859, 0.012905231, 0.013387854, -0.020918109, 0.0035800114, 0.026775708, 0.005920407, -0.018233927, -0.008759954, 0.0005437783, -0.022081695, 0.0071996907, -0.002963509, 0.004092386, 0.057967756, -0.015285294, -0.008978127, 0.027740957, 0.015853863, 0.047178138, -0.018366152, -0.0064889775, 0.029777233, 0.0141217075, 0.007847597, 0.02200236, 0.031125935, 0.010611114, -0.00663112, -0.005940241, 0.017215788, -0.019992528, -0.01644888, -0.013447356, 0.001490845, 0.007893875, 0.016276987, -0.0062939445, 0.00032333322, 0.0020230536, -0.025360893, 0.028587202, -0.009645866, 0.01459772, -0.012376328, 0.03202507, -0.006059244, 0.010888788, 0.014518384, -0.034405135, 0.023364285, 0.018895056, -0.009361581, -0.0011255714, 0.00663112, 0.016885225, 0.01609187, -0.006750123, -0.035304267, 0.0022660184, 0.027714511, 0.01680589, -0.03686453, -0.008045935, 0.052943178, -0.0091169635, -0.0066840104, 0.018405821, 0.00027374856, 0.0005235312, 0.0138969235, 0.018075256, 0.0005850988, -0.0074971984, 0.0011255714, -0.011054071, -0.0022048638, 0.0043931995, 0.021142893, -0.02472621, -0.007232747, 0.0014858865, -0.00062228733, -0.017903363, -0.0013495288, -0.0001454483, 0.0027370725, 0.0060129645, 0.0364943, -0.04601455, -0.008713675, -0.017215788, -0.017784359, -0.007100521, -0.014610942, -0.027978962, 0.0046179835, -0.010267328, 0.036785197, -0.019542962, 0.028719427, 0.004343615, 0.0067765685, -0.018075256, -0.004462618, 0.010121879, -0.0024957606, -0.00883929, 0.0017007533, -0.011371412, -0.007788095, 0.002418078, -0.01053839, -0.018458711, -0.0048328503, 0.0035072872, 0.0043568374, -0.006389808, 0.027635176, -0.002768476, -0.033479553, -0.0069749067, -0.00096276856, -0.0034048124, 0.012773004, -0.01979419, -0.003675875, -0.011655698, -0.026709596, -0.0009206216, -0.009295468, 0.011391246, 0.0050510224, 0.0027486421, 0.0024246892, -0.01264739, 0.004687402, -0.0058377655, 0.0117945345, -0.009388026, 0.010545001, 0.020481765, -0.000089768866, -0.022425482, -0.013487023, -0.008316998, -0.019503294, 0.025942687, 0.0076889256, -0.03355889, -0.0071071326, -0.019106617, -0.015430742, 0.021724686, 0.0019652047, 0.011113572, -0.019410737, -0.023615515, 0.000523118, 0.019027282, -0.015853863, -0.011887092, -0.021804022, -0.013473801, -0.0049518533, -0.00071773777, -0.003194904, 0.046411227, -0.0108689545, 0.04003795, -0.0026626955, 0.03146972, -0.005804709, -0.013645695, 0.0046973187, -0.010148324, 0.02292794, 0.0310466, 0.018709939, 0.020005751, 0.028534312, -0.02134123, 0.044031166, -0.00021548661, 0.018458711, -0.038795028, -0.00930208, -0.013738252, 0.029486336, -0.0019503294, 0.008812845, -0.02755584, 0.004852684, -0.013301908, 0.000006940559, 0.017453795, -0.005249361, 0.0069352393, -0.023205614, -0.02040243, -0.0060493266, -0.017110009, 0.011417692, 0.006882349, -0.019556185, 0.015893532, -0.0028874793, -0.0023387424, -0.0034610082, -0.009427694, -0.009705368, 0.002194947, -0.008191383, 0.021804022, -0.016250541, 0.0053320024, 0.037393436, -0.014174597, 0.031073045, 0.004108914, 0.010029321, 0.018538047, 0.007675703, -0.012568055, -0.0080525465, 0.0013487024, 0.03234241, -0.009983042, -0.014782836, 0.0069418503, -0.014346491, -0.0009875608, -0.024924548, 0.035145596, 0.009592976, -0.010902011, 0.0047568204, 0.006194775, 0.011344967, 0.028349195, 0.0062410543, -0.0027172386, 0.011080516, 0.012303604, 0.012263936, -0.009844205, -0.004766737, -0.0062079974, -0.005748513, -0.01979419, -0.006036104, -0.018630605, -0.00050204457, -0.013830811, 0.0015338184, -0.00418825, -0.020799106, -0.016792666, -0.0034015067, 0.034352243, 0.00915002, -0.019767746, 0.016462103, 0.014346491, -0.009672312, -0.032606862, -0.010035932, -0.0035238154, -0.018934723, 0.012204434, -0.015946422, 0.022597376, -0.00081194856, 0.002740378, 0.0088921795, 0.0056361216, 0.011549917, -0.0088789575, 0.008720286, 0.007424474, -0.0022263506, 0.0020131366, -0.023165947, -0.037181873, 0.014756391, 0.011424302, -0.0057385964, -0.014690278, -0.018709939, -0.005536952, -0.0064228643, 0.00418825, -0.023787407, 0.012845729, -0.009487196, -0.011754867, -0.008746731, -0.013844033, 0.026643483, 0.009070684, -0.016554661, -0.024078304, -0.013553137, 0.011146628, 0.11075226, -0.007854208, 0.0024098137, 0.005685706, 0.0032081266, -0.00603941, -0.022161031, 0.0004933672, 0.0014486981, -0.001134662, 0.007345139, 0.008237663, -0.0019057032, 0.007120355, -0.009864039, 0.03115238, -0.00041051954, -0.00344448, -0.013063901, -0.020997444, 0.013222572, -0.002824672, 0.018366152, 0.025889797, 0.007523644, -0.019648742, -0.007391418, 0.02168502, -0.0019255371, -0.018524824, -0.00021156116, -0.004826239, -0.001088383, -0.0071468004, 0.0000106013, -0.002963509, 0.015430742, 0.029036768, 0.035806727, -0.016924892, 0.039271038, 0.02503033, 0.019648742, -0.02636581, 0.0035634832, -0.00044254295, -0.016435657, 0.012792839, 0.008270719, -0.03469603, 0.052599393, 0.008270719, -0.0052824174, -0.0059534633, 0.023668405, 0.011159851, -0.018128147, -0.0064856717, 0.009606198, -0.015258849, 0.00291723, -0.028851653, 0.019133061, -0.012323437, -0.01516629, -0.027846737, -0.019820636, 0.0024974134, -0.01377792, -0.00067063235, -0.022703156, -0.009156631, -0.012303604, -0.023311395, 0.006174941, 0.0073980293, 0.012343272, -0.015721638, -0.00033097752, 0.019146284, 0.011761478, -0.019542962, -0.0057452074, -0.0076823146, -0.002343701, 0.007840985, 0.014941507, 0.007847597, -0.004029579, 0.008812845, 0.029168995, 0.01876283, 0.01125902, -0.010611114, 0.00021734604, -0.0037948783, -0.0016445575, 0.028587202, 0.015086955, 0.0035899284, 0.0009900401, -0.019622298, -0.00704102, -0.0062410543, 0.0027106274, 0.009652478, -0.01573486, 0.0152985165, 0.0046774847, -0.02595591, 0.0115565285, -0.021989137, 0.010961512, -0.011179685, 0.011781312, -0.00055782724, -0.0033238241, -0.0012619293, 0.02066688, -0.014372936, 0.006399725, -0.022332925, 0.011014403, 0.01927851, -0.008733509, 0.003798184, 0.017744692, -0.036732305, 0.0077087595, 0.005454311, -0.0038676024, 0.01696456, -0.00037973575, 0.0058212373, -0.030517697, -0.012006096, 0.012482109, 0.015946422, 0.0031899456, 0.001283416, -0.0055898423, 0.01737446, 0.03633563, 0.015642302, -0.002953592, -0.02446176, -0.011364801, -0.023033721, -0.003798184, 0.03726121, -0.021513125, 0.014505162, -0.008971515, -0.0023007276, 0.0009231008, -0.03916526, -0.023364285, 0.008145104, 0.020997444, 0.025889797, 0.0302268, -0.02107678, 0.03720832, -0.009936763, 0.013361409, -0.00080492406, -0.015972868, -0.0035172042, -0.041968442, 0.012369717, 0.020389207, 0.011530083, 0.0016420782, -0.026947603, 0.010465666, 0.009983042, 0.011549917, -0.013923368, -0.0075699226, -0.012442441, 0.0031635005, -0.0003237464, -0.009196299, 0.007920321, -0.003556872, 0.0043105586, 0.036520746, 0.0029155773, -0.0025073302, -0.016224096, 0.0094541395, -0.016409213, 0.01192676, 0.0008702105, 0.014796059, 0.002148668, -0.013414299, -0.026154248, -0.02235937, 0.011801146, 0.012442441, -0.0016685233, 0.008898791, 0.0063931136, -0.01094829, 0.013963036, 0.002611458, -0.015880309, 0.01789014, -0.0050378, -0.0035800114, -0.016885225, 0.0073120827, -0.040117282, 0.005748513, 0.0027536007, -0.022676712, 0.008674008, -0.024699764, 0.0045783157, -0.030676367, 0.0008602936, 0.038742136, 0.010551613, 0.020812329, 0.0017354626, 0.011278854, -0.0068559037, -0.016686887, -0.007424474, 0.0022759351, 0.014452271, 0.0141217075, 0.0020296648, -0.0016784403, -0.017810805, -0.009526864, -0.015906755, -0.012092043, 0.0143597135, -0.009090519, 0.01352008, -0.012620945, -0.008270719, -0.013288685, 0.027978962, -0.0049882154, -0.0044791466, -0.008726898, -0.015946422, -0.02153957, 0.012938287, -0.016753, 0.022531264, 0.015933199, -0.013361409, 0.03834546, -0.001832979, -0.008773177, -0.012111876, -0.02524189, 0.024792323, 0.009758258, 0.029327665, 0.01141108, 0.01022766, -0.016726553, 0.008409556, 0.011424302, 0.023192393, 0.0021354454, -0.01346719, -0.016435657, 0.0051072184, -0.0037485992, -0.015338183, -0.009374804, -0.02251804, -0.026815377, -0.022703156, 0.01582742, 0.016951337, -0.014491939, -0.011523472, -0.018154591, 0.0061418847, -0.00039378472, -0.009599588, 0.00061898166, -0.026088135, -0.010809453, -0.012680447, 0.0011892051, 0.00817155, -0.011060682, -0.007834374, -0.0015015884, 0.018974392, -0.026379032, 0.01794303, -0.029063214, 0.005731985, -0.015721638, 0.013202738, 0.018855387, -0.017043896, 0.021883357, -0.00976487, -0.0063501406, 0.0006817889, -0.021010667, -0.0034411745, -0.019701632, -0.015999312, -0.0065418677, 0.0036130678, -0.015615858, -0.017519908, -0.035330713, 0.029486336, 0.0007094736, -0.015351406, -0.00010252659, -0.0019618992, 0.02565179, 0.0023751045, 0.024382424, -0.007807929, -0.016157983, -0.008012879, -0.0076823146, 0.020256981, -0.0023784102, -0.01125902, -0.017229011, -0.009163243, -0.0073980293, 0.018802498, 0.0007470753, 0.004786571, 0.038133897, 0.022782492, 0.0136721395, 0.0048394613, -0.00033986144, 0.0070608538, 0.005771653, -0.026167471, -0.021394122, -0.0039237984, 0.01922562, 0.03868925, 0.00899796, -0.021658573, -0.010809453, -0.010604503, -0.011966428, 0.0051733316, 0.003074248, 0.017757915, 0.051620923, 0.0036593468, -0.016673664, 0.013024233, 0.004826239, 0.02750295, -0.00817155, -0.012865563, 0.013037456, 0.01758602, -0.0006045195, 0.010187992, -0.03263331, -0.015814196, 0.029274775, 0.0018957863, -0.009672312, 0.0011966428, -0.015748084, -0.0054972842, -0.041386653, 0.012250713, 0.007530255, 0.0047204583, 0.018286817, -0.02134123, 0.0033915897, -0.007391418, -0.0035304269, -0.0032180436, -0.0002681703, -0.009361581, -0.013249017, 0.02036276, -0.010749951, -0.02107678, -0.017242234, -0.01644888, 0.02483199, -0.0060823835, 0.0042576683, 0.020071864, 0.014372936, -0.013963036, -0.008350055, 0.005474145, -0.0029321054, -0.029512782, -0.023046944, -0.017718246, 0.0016106745, -0.021618906, -0.011490415, -0.009209521, 0.009282245, 0.01459772, 0.024567539, -0.0021073474, 0.02168502, 0.0021040419, -0.025770793, 0.0014296906, 0.0042279176, -0.009553309, -0.0041254424, -0.012396161, 0.0018395904, -0.016753, -0.0076889256, -0.0010991263, -0.022782492, 0.004224612, 0.014518384, 0.015100177, -0.01315646, 0.0036362074, 0.19643453, -0.006902183, -0.01223088, 0.0163431, -0.0065352563, 0.018723162, 0.0247791, -0.0050807735, -0.0047832653, -0.009196299, -0.014928284, 0.027529396, 0.0019933027, 0.0026180693, 0.0016205915, -0.01639599, -0.02153957, -0.017202567, -0.024131194, -0.03316221, -0.00085698796, -0.0063600573, -0.03181351, -0.009037628, 0.0032907678, -0.0050378, -0.0010346663, -0.01835293, 0.01361925, 0.026088135, 0.0005751819, -0.016819112, -0.009434305, 0.0023354369, -0.020997444, -0.0067402064, 0.008310387, 0.0040626354, 0.0040890803, 0.030306136, -0.015959645, 0.021037113, -0.0009916929, 0.0070872987, -0.01161603, 0.017096786, -0.001370189, -0.0042080837, 0.0008140146, 0.014108485, -0.02606169, -0.010472277, 0.021261897, 0.019966085, -0.011735033, -0.010908622, 0.0016586065, 0.029697897, -0.01830004, -0.011034236, -0.0038246291, 0.031787064, -0.0079401545, 0.0075500887, -0.009844205, 0.022161031, -0.0044097276, 0.0059600743, 0.011959816, -0.019371068, 0.0037915725, -0.015020842, -0.010968124, -0.0062741106, -0.00012179228, -0.027053382, 0.03377045, 0.005725374, 0.0026891406, -0.0011602807, -0.00403619, -0.0076889256, 0.0040791635, -0.0040989975, -0.018895056, -0.0197413, 0.014756391, 0.0057914867, -0.012296992, -0.017757915, 0.008422779, -0.020137977, 0.003537038, -0.0011040848, 0.0061286623, 0.031734172, -0.011748255, 0.03207796, 0.008204606, -0.0043270867, -0.02652448, -0.03501337, 0.0050609396, 0.015615858, -0.027476504, 0.0026660012, 0.00057104987, 0.022861827, -0.012098653, -0.0024461758, 0.01022766, -0.008350055, 0.0114441365, 0.0022081695, -0.0044130334, 0.018009143, -0.0013867173, -0.016620774, -0.0060460214, -0.01459772, 0.008164939, -0.013249017, 0.005748513, 0.005232833, -0.024950994, -0.011490415, -0.013480413, 0.021552794, 0.011285465, -0.03604473, 0.0041915555, -0.0052096937, 0.013037456, -0.012449052, -0.013037456, 0.01639599, 0.0051997765, -0.002267671, 0.015047288, 0.018643826, 0.013976259, 0.0052394443, 0.0059534633, 0.010016099, -0.0016528215, -0.03670586, 0.023483288, 0.008250885, -0.0051997765, -0.012607723, -0.019133061, -0.005798098, -0.012991177, -0.001120613, 0.015272071, -0.03279198, -0.040646188, -0.014994397, -0.009031017, 0.014108485, -0.011424302, 0.021420566, 0.0053353077, 0.0052361386, -0.012607723, -0.0076823146, -0.17136453, -0.0011024319, 0.011351578, -0.0062278314, 0.008700453, 0.0017106703, 0.011992873, 0.0048758234, -0.004568399, -0.0052460553, 0.02729139, -0.013407689, -0.041809775, 0.0023552708, 0.025612123, 0.031337496, -0.008925236, 0.017004227, 0.013989481, 0.005252667, 0.02344362, 0.023879966, -0.0006917058, 0.013949813, 0.0005198124, 0.0051072184, 0.0040791635, 0.0046576513, -0.012574666, -0.013698584, -0.012654002, -0.00344448, -0.006862515, 0.012944899, 0.023324618, 0.004743598, -0.029724343, 0.006307167, 0.0016453839, 0.0093549695, -0.008469057, 0.035648055, 0.01454483, -0.0115697505, 0.011344967, 0.015496855, -0.013738252, -0.0026610426, -0.005923712, -0.007953377, 0.01609187, -0.02698727, 0.011483804, -0.014796059, 0.024408868, 0.009778093, -0.0014437396, 0.007001352, 0.022068473, -0.011701977, -0.00007365386, -0.023377508, 0.012964732, -0.010445832, -0.018114924, -0.04009084, -0.0056427326, 0.0071269665, -0.03300354, 0.028666537, -0.025850128, -0.017440572, 0.007966599, -0.026484812, 0.012409384, -0.0022032112, -0.009778093, -0.005798098, -0.015430742, -0.0028775623, -0.011629253, 0.035304267, -0.03295065, 0.019384291, -0.009513641, 0.017387683, -0.019873526, -0.011113572, -0.012052375, -0.010531778, 0.010459054, -0.034458023, -0.01876283, -0.00026589766, 0.008217828, 0.025202222, 0.0009792967, -0.005712151, 0.005150192, -0.01794303, -0.0048956573, -0.010895399, -0.007345139, -0.005725374, 0.036917422, -0.009447528, 0.042603128, 0.017969476, 0.03094082, -0.0061617186, 0.01459772, 0.0040031336, 0.004340309, 0.01979419, -0.0055799256, 0.020349538, -0.019040504, -0.019648742, 0.019780967, -0.0012842424, 0.03839835, -0.0005590669, -0.023165947, -0.011067293, 0.014015927, 0.012303604, -0.10461699, -0.009315303, 0.00067393796, 0.021195784, -0.017506685, 0.009427694, 0.0045055915, 0.00096194213, 0.015919978, 0.016435657, -0.014095262, 0.0028676454, -0.004730375, -0.0136721395, 0.010306995, -0.0073186937, -0.013401077, -0.0090045715, -0.019344624, 0.009242578, -0.016686887, 0.0007702148, 0.012528387, -0.012025929, -0.022689935, -0.009976431, -0.032236632, 0.02750295, 0.004158499, 0.01855127, 0.002371799, -0.0053320024, 0.007715371, -0.03252753, -0.013500246, 0.011973039, -0.008469057, -0.0022924636, 0.0213809, -0.04842106, 0.018895056, 0.0015858823, 0.007576534, -0.024964217, 0.014994397, 0.0020412346, -0.005249361, 0.0014792753, 0.009348359, -0.03638852, -0.028402084, -0.01084251, -0.019979307, -0.0035304269, 0.0036064566, -0.014994397, 0.017652133, 0.01305729, 0.007907098, 0.006667482, 0.0028676454, -0.020005751, -0.012991177, 0.03001524, -0.00046609566, 0.015615858, -0.02935411, -0.0009925193, 0.033796895, -0.019040504, -0.014901839, 0.009533474, -0.010121879, 0.026458368, -0.038054563, 0.009956597, -0.0030048296, -0.0019519823, 0.016872002, -0.001142926, -0.014941507, -0.02930122, 0.004611372, -0.029512782, 0.030887928, -0.0018015754, 0.010624337, -0.0044791466, -0.007993045, -0.0056790947, 0.0019602464, 0.011173073, 0.0023222142, -0.00022499033, 0.0024511344, 0.015443964, 0.018987615, -0.02349651, -0.008740121, 0.00029730127, -0.004750209, -0.017969476, -0.06442037, 0.006816236, 0.0019833858, 0.0063038613, -0.0054675336, -0.01161603, 0.032818425, -0.030094575, 0.009685534, -0.0012520123, -0.0013090346, 0.0085285595, 0.015959645, -0.0006574098, -0.00688896, -0.019133061, -0.0008057505, 0.009672312, 0.019913195, 0.008145104, -0.012290381, 0.0016139803, 0.026405476, 0.014875393, -0.002168502, 0.012792839, -0.011840814, 0.003464314, 0.0069682957, -0.0073781954, 0.018842166, -0.03165484, -0.017242234, 0.006789791, -0.009130186, -0.012263936, -0.015258849, 0.0036692638, 0.008865735, 0.0272385, -0.004009745, -0.017612467, 0.022584153, -0.023760963, 0.004231223, 0.004287419, -0.020891665, 0.022425482, 0.007986434, -0.0030345803, 0.010459054, 0.013844033, 0.012283769, -0.027899627, -0.006250971, -0.023430398, 0.0122573245, -0.004128748, 0.013830811, -0.016766222, 0.022861827, -0.011192908, 0.03665297, -0.00212057, -0.009031017, -0.024170863, -0.0010230965, -0.0064393925, 0.014015927, -0.005956769, 0.000146378, -0.008436001, 0.010604503, 0.013169682, -0.00516672, 0.0012321784, -0.022332925, -0.0022643656, -0.03993217, 0.02050821, 0.01577453, -0.0043667546, -0.022372592, -0.001152843, 0.010002876, 0.0036262905, -0.017876917, 0.006406336, -0.009401249, 0.019569406, -0.03033258, -0.01269367, 0.0020412346, 0.009989654, -0.0014627471, 0.04101642, 0.0011189602, -0.023046944, 0.0013230836, 0.024250198, 0.01207882, -0.0062377485, -0.010452444, -0.020825552, 0.006693927, -0.005305557, -0.018339708, -0.041307315, -0.012296992, 0.0070542423, 0.0019371068, 0.0117945345, -0.020032197, 0.017797582, -0.015443964, 0.00537167, -0.00015474542, -0.0117747, -0.011140017, 0.017334793, 0.016250541, 0.006019576, 0.017612467, -0.017982699, 0.010366497, 0.0029949127, 0.015086955, -0.000027813887, -0.008660785, -0.008713675, -0.0050873845, -0.0117945345, -0.016118316, -0.0022015583, 0.006518728, -0.0047766543, 0.0055501745, 0.039747052, -0.034061346, 0.049425974, 0.0023883271, -0.0035601775, 0.00863434, -0.003897353, 0.016237319, 0.006436087, -0.00037828952, -0.017797582, -0.019450404, 0.0009809496, 0.0036461244, 0.013176293, 0.0036461244, -0.01094829, -0.018260373, 0.00035246418, 0.012885396, -0.006796402, -0.015972868, 0.027899627, -0.0077021485, 0.027608732, 0.01696456, -0.0014486981, -0.017969476, 0.015642302, -0.00477996, -0.0048890463, -0.020058641, 0.008323609, 0.013017623, -0.01886861, -0.008204606, 0.016303431, -0.010029321, -0.001018138, -0.0332151, 0.010525168, 0.032871313, 0.011549917, 0.010928456, -0.014253933, -0.011384634, 0.00894507, 0.034616694, -0.016872002, -0.010987958, -0.011953205], 26 'numCandidates': 150, 27 'limit': 10 28 } 29 }, { 30 '$project': { 31 '_id': 0, 32 'title': 1, 33 'plot': 1, 34 'year': 1, 35 'score': { 36 '$meta': 'vectorSearchScore' 37 } 38 } 39 } 40 ] 41 42 # run pipeline 43 result = client["sample_mflix"]["embedded_movies"].aggregate(pipeline) 44 45 # print results 46 for i in result: 47 print(i) 48
1 {'plot': 'In this magical tale about the boy who refuses to grow up, Peter Pan and his mischievous fairy sidekick Tinkerbell visit the nursery of Wendy, Michael, and John Darling. With a sprinkling ...', 'title': 'Peter Pan', 'year': 1960, 'score': 0.748110830783844} 2 {'plot': 'A down-on-his-luck inventor turns a broken-down Grand Prix car into a fancy vehicle for his children, and then they go off on a magical fantasy adventure to save their grandfather in a far-off land.', 'title': 'Chitty Chitty Bang Bang', 'year': 1968, 'score': 0.7442465424537659} 3 {'plot': 'A young man comes to the rescue of his girlfriend abducted by thieves and brought to Rio. An extravagant adventure ensues.', 'title': 'That Man from Rio', 'year': 1964, 'score': 0.7416020035743713} 4 {'plot': 'A boy raised by wolves tries to adapt to human village life.', 'title': 'Jungle Book', 'year': 1942, 'score': 0.7387760877609253} 5 {'plot': 'A pilot, stranded in the desert, meets a little boy who is a prince on a planet.', 'title': 'The Little Prince', 'year': 1974, 'score': 0.7378944158554077} 6 {'plot': 'A red balloon with a life of its own follows a little boy around the streets of Paris.', 'title': 'The Red Balloon', 'year': 1956, 'score': 0.7342712879180908} 7 {'plot': 'A poor boy wins the opportunity to tour the most eccentric and wonderful candy factory of all.', 'title': 'Willy Wonka & the Chocolate Factory', 'year': 1971, 'score': 0.7342107892036438} 8 {'plot': 'An apprentice witch, three kids and a cynical conman search for the missing component to a magic spell useful to the defense of Britain.', 'title': 'Bedknobs and Broomsticks', 'year': 1971, 'score': 0.7339356541633606} 9 {'plot': 'Arriving home to find his native land under the yoke of corrupt merchants, an adventurer named Sadko sets sail in search of a mythical bird of happiness.', 'title': 'Sadko', 'year': 1953, 'score': 0.7339220643043518} 10 {'plot': "A young boys' coming of age tale set in a strange, carnivalesque village becomes the recreation of a memory that the director has twenty years later.", 'title': 'Pastoral Hide and Seek', 'year': 1974, 'score': 0.733299970626831}
Atlas Vector Search filters the documents based on the year
field value that
ranges between 1955 and 1975. It returns documents that summarize
children's adventures in the plot for movies released between 1955 and
1975.
Tip
See also: Additional Filter Examples
The How to Perform Semantic Search Against Data in Your Atlas Cluster tutorial demonstrates other
pre-filters in semantic search queries against the embedded data in
the sample_mflix.embedded_movies
collection.
ENN Example
The following query uses the $vectorSearch
stage to search
the plot_embedding
field using vector embeddings for the string
world war. It requests exact matches and limits the results to
10
documents only. The query also specifies a $project
stage to do the following:
Exclude the
_id
field and include only theplot
,title
, andyear
fields in the results.Add a field named
score
that shows the vector search score of the documents in the results.
1 db.embedded_movies.aggregate([ 2 { 3 "$vectorSearch": { 4 "index": "vector_index", 5 "path": "plot_embedding", 6 "queryVector": [-0.006954097,-0.009932499,-0.001311474,-0.021280076,-0.014608995,-0.008227668,-0.013274779,-0.0069271433,-0.009521453,-0.030943038,0.017304381,0.015094165,-0.010397454,0.010943269,0.012230316,0.025943095,0.02583528,0.001368751,0.009777515,-0.016024074,-0.013989056,0.00685639,0.030242238,-0.023881124,-0.011057823,-0.0056906347,-0.00055929273,-0.03199424,0.0072168973,-0.023166848,0.0033490178,-0.024069803,-0.023557678,-0.020862292,0.007452744,-0.019002475,0.007850314,-0.032856762,-0.012951332,0.003005356,-0.003739849,0.010053792,0.019541552,0.007702067,-0.035498243,-0.00918453,-0.0143529335,0.000249955,-0.011866439,0.019703276,0.0076481593,0.025161434,-0.015714103,-0.0076818517,-0.023180325,-0.0032883717,-0.02315337,0.015188503,0.031347346,-0.008739791,0.01454161,0.014824626,-0.025107525,0.0012558816,-0.012803086,-0.013146748,-0.01652272,0.01283004,-0.019352876,-0.010444623,0.04706145,0.030754361,0.008820653,0.011657547,0.014878534,-0.010181823,0.00041673204,-0.009103668,-0.0055255424,0.00579845,0.024110233,-0.020404076,-0.0066272817,-0.005299804,0.019649368,0.007729021,-0.0066845585,0.025592696,0.00575465,-0.014824626,0.00033334352,-0.008591545,0.004164372,0.028085928,-0.020875769,-0.00448108,-0.009258653,0.02535011,-0.0025538788,-0.059082873,-0.0074055744,0.005950066,-0.014164257,-0.016185796,-0.015768012,-0.01309284,0.0030222023,0.0028436328,0.0037095258,-0.0068462817,-0.010963485,0.018988999,0.010929792,-0.03967609,0.016994413,-0.023503771,-0.0037903874,-0.012075332,-0.005923112,-0.01902943,0.017978229,-0.005993866,0.024015894,-0.017722167,0.010875884,0.0153637035,-0.04045775,-0.0016568204,-0.0074190516,0.0011084777,0.033018485,0.021536138,0.025794849,-0.019622413,-0.041724585,0.014743765,-0.011111731,0.0065666353,-0.019851523,-0.035174794,0.007270805,0.02698082,-0.010929792,-0.020148015,-0.009689915,0.032182917,0.015700627,0.013786903,-0.0021647324,-0.0063644815,0.027317744,0.004403588,0.03158993,-0.0039116796,0.02029626,0.04191326,-0.0050504804,0.008416344,-0.0034602026,0.010485054,-0.0030996946,-0.0212666,0.0043934803,-0.016765304,-0.00039441086,0.025538787,0.008483729,0.017479582,-0.0061454815,-0.018220814,-0.0025589326,0.0102829,-0.045498125,0.029784022,0.017169613,0.020592753,0.012445947,0.021630477,-0.031050853,-0.011327362,-0.024689741,0.0048988652,0.022129124,0.0114621315,-0.026091343,0.015067211,0.004723665,0.017722167,0.014608995,-0.016805734,0.0042250184,0.027843343,0.03264113,0.007034959,-0.6852751,-0.019986292,0.003827449,0.0032462562,0.006115158,-0.001972686,0.001937309,0.015956689,-0.010437884,0.00803899,-0.01401601,-0.00026869634,-0.033207163,-0.00623982,-0.0048449575,-0.013193917,-0.00426208,-0.013207395,-0.014379887,0.017991705,0.0007264909,0.023517247,-0.00725059,0.0071832053,-0.003466941,-0.0072842822,0.0028234175,-0.02460888,0.0044608647,-0.008746529,-0.025713988,0.012499855,0.004882019,0.010525485,0.05250613,-0.003387764,-0.021212691,0.026549557,0.034123596,0.014325979,-0.0080592055,-0.012189886,-0.005970281,0.0115093,0.0021731553,0.033557564,0.020929677,-0.02130703,0.022991648,-0.03123953,0.0102829,-0.0067721587,0.008510683,0.010013361,0.031320393,0.010646777,0.015215457,-0.019797614,0.0022186402,-0.0010351969,0.0015523742,0.021630477,0.00751339,0.0062162355,-0.016468812,0.018840753,-0.02544445,0.030943038,0.008295052,-0.005700743,-0.0033557562,0.020053675,-0.012722225,-0.016778782,0.025511835,0.025538787,0.022802971,-0.017708689,-0.009615792,-0.00733819,0.0049224496,-0.021590047,-0.021158785,0.022034785,0.046872772,-0.021064445,-0.024811033,0.0043429416,-0.006169066,-0.0044406494,-0.003357441,0.006445343,-0.01801866,-0.0082074525,0.0037802798,0.02258734,0.0018598167,-0.0101548685,0.020134538,-0.008214191,-0.0004830638,0.00421828,0.0048719114,0.0087869605,-0.008335483,0.023503771,-0.030161375,0.0055929273,0.054069456,-0.010006622,0.018975522,0.015956689,-0.018530782,0.003669095,0.014662903,-0.023126416,0.011300408,0.021563092,-0.00106552,-0.03269504,0.020282784,-0.023665493,0.025242295,-0.01801866,-0.008537637,-0.00083472754,0.02130703,-0.008780221,0.0080592055,-0.0012971548,0.014838103,0.0056704194,0.015794965,0.001546478,0.013072625,0.0057310658,0.011711455,-0.020997062,0.010289638,0.0041070953,-0.025592696,0.012661578,-0.013436502,0.013348902,0.014312503,-0.023894602,-0.018517306,-0.0105928695,-0.02140137,0.0076885903,0.03220987,-0.0042283875,-0.04649542,-0.000022110593,0.00013803327,-0.0046293265,-0.0036286642,-0.028598052,-0.0042856648,-0.029406667,0.026765188,0.0027711943,-0.0059298505,-0.00311991,0.016293611,-0.027182974,-0.011623855,0.0030508407,-0.0035747564,-0.018032135,0.03045787,0.0011337469,-0.004780942,0.012055117,-0.0081333285,0.02908322,-0.008092898,-0.0015944897,0.014716811,0.014325979,-0.0037061565,-0.0074325283,-0.01854426,-0.0070821284,-0.003598341,-0.01718309,-0.0108826235,0.014959396,-0.019366352,0.017722167,0.009528192,0.022439092,-0.01630709,-0.003625295,-0.00413068,-0.007311236,-0.008503945,-0.006024189,0.038867474,0.030943038,0.015956689,0.007196682,0.013699302,0.0025471402,0.026792143,-0.031832516,-0.018867707,-0.03897529,0.04679191,0.00421828,0.01634752,-0.004120572,-0.009696653,-0.011414962,0.011980994,0.045659848,-0.010080745,-0.0045720492,-0.020794908,-0.0030205175,-0.00896216,-0.0071427743,0.006559897,0.0045147724,-0.032991532,0.0059332196,0.0033153256,0.00426208,0.0063779587,-0.025943095,-0.021495707,-0.008268098,-0.002429217,0.0102829,-0.0048786495,0.003584864,0.004737142,-0.029244944,0.027169496,0.010599608,-0.008517422,-0.0016652435,0.023544202,-0.022398662,0.010202038,0.0029211252,0.021185739,-0.01708875,-0.03396187,0.025121003,-0.009838161,0.015633242,-0.015525427,0.003743218,0.0044676033,-0.021819154,-0.006802482,-0.023126416,0.028112883,0.03045787,0.015255888,-0.008685883,-0.010943269,-0.0039386335,-0.0014950972,-0.009043022,-0.0023264554,-0.0028975406,-0.0021377786,0.002860479,-0.0010166661,-0.01173167,0.03040396,-0.028005067,-0.00509765,-0.008463514,0.019959338,-0.012533547,-0.012782871,-0.0055558654,0.004807896,-0.018800322,0.005582819,0.017991705,-0.005505327,-0.008382652,0.0011404854,-0.0035073718,-0.017587397,0.012890686,-0.0015363704,-0.000308706,0.011603639,-0.0042452337,-0.027129065,-0.0086387135,0.023786787,-0.024352817,-0.015175027,0.017546967,0.0064318664,0.0100874845,-0.008605022,-0.006529574,0.014703333,-0.0010318276,-0.012290963,-0.014622472,-0.008382652,-0.000661212,0.0044170646,0.009386684,-0.0030660022,0.0033102715,-0.007095605,0.007978344,-0.016980935,-0.0040262337,0.022344755,0.0077357595,0.0063341586,-0.016482288,-0.028220698,-0.026899958,0.08291009,0.014002534,0.00075428706,0.013018717,0.0013485356,-0.0223178,-0.016697919,-0.018584691,0.0057378043,0.007924437,0.0032850024,-0.01735829,0.029730113,0.021684386,-0.008382652,0.017021365,0.0030811639,-0.008025514,0.0043564187,-0.000044694985,-0.0038375566,-0.012924379,-0.012230316,0.0345279,-0.014689857,-0.019406782,0.008780221,0.0092923455,-0.01555238,-0.01920463,-0.01827472,-0.00305421,-0.017573921,0.016320566,0.02548488,0.02105097,0.012823301,0.03431227,0.026589988,-0.025606172,0.007755975,0.0019693167,0.0096494835,-0.034069687,0.0067721587,0.0004190484,0.005508696,0.033207163,-0.0011792317,-0.012648102,0.022829924,0.015821919,-0.035956457,-0.038732704,-0.020740999,0.0063880663,-0.010471577,-0.006933882,0.005936589,0.015889304,-0.00852416,-0.031455163,0.009305822,0.0051178653,-0.027452512,-0.015700627,-0.017762598,-0.005869204,-0.0065531586,-0.011879916,-0.008220929,-0.0053503425,-0.0026920172,-0.00038830412,0.019959338,-0.010444623,-0.00047548304,-0.015040257,0.0008330429,0.008005298,-0.0075336057,-0.02117226,-0.027250359,-0.018962044,-0.006138743,0.014918964,-0.014757241,-0.013867764,0.0006961678,0.01726395,-0.0039352644,0.005724327,0.019878477,0.009494499,0.0071832053,-0.0023652017,0.004865173,0.029784022,0.002390471,0.0005854043,0.00034387235,0.0053975116,-0.011650808,0.005218942,0.007136036,-0.0091440985,0.005879312,0.028193744,-0.024662787,-0.0029447097,0.009636007,-0.029730113,0.00025206077,0.006745205,0.011522777,0.02035017,0.026131773,0.029972699,0.008012037,-0.012466162,0.012459424,-0.01836906,0.0051515577,0.022196509,-0.015970165,0.0037465873,-0.008396129,-0.009494499,-0.0036657257,0.011219546,-0.01823429,0.013524102,0.015134595,0.020269306,-0.0028891175,0.008456775,0.0051650344,0.011131947,-0.0038948336,-0.010909577,-0.010485054,-0.026859527,-0.005475004,-0.0036589873,0.0034602026,-0.026253065,-0.010350284,0.0137734255,0.0030828484,0.012526809,-0.026131773,-0.02363854,0.00024321652,-0.015956689,-0.0042991415,-0.027762482,-0.012782871,-0.016940504,0.01256724,0.03598341,0.026387835,0.0013763318,0.0041946955,0.0017520012,-0.007755975,-0.011179116,0.003537695,0.011522777,-0.035929505,0.021037493,0.041859355,0.034770485,-0.012769394,0.0059534353,0.02851719,0.017749121,-0.011017392,0.0059568044,-0.02105097,-0.011233023,0.0095079765,-0.0019002475,-0.006472297,-0.00826136,-0.011495824,-0.024056325,0.00628362,0.0028689022,0.0050808038,0.00632742,0.020228876,-0.0029767177,0.0327759,-0.016859643,0.0006439447,-0.01516155,0.015889304,0.0032765793,-0.0017570552,0.016509242,0.0076481593,0.0033254332,-0.012513332,-0.0073718824,-0.012237055,0.025997004,-0.0052122036,-0.0007530236,-0.01739872,-0.020188445,-0.0005908793,-0.011212808,0.008840868,-0.015741058,0.0034197718,-0.0033456485,-0.010262684,0.010080745,-0.016751828,-0.04415043,0.010202038,0.0058557275,0.023369001,0.009238438,0.04029603,0.009743823,-0.006802482,-0.01502678,0.01634752,-0.018301675,0.011313885,0.030080514,0.009501237,0.000942543,-0.007755975,-0.015242411,0.003898203,-0.017236996,-0.026172204,0.02394851,0.0065834816,0.021617,0.0054514194,-0.039487414,-0.021549616,0.018813798,-0.025848757,0.0026566405,-0.011199331,-0.024635833,-0.01129367,0.010181823,-0.033638425,0.033072393,-0.008537637,-0.02597005,0.010444623,-0.037169382,-0.0003693522,0.008793699,-0.006647497,0.014716811,-0.026023958,-0.011455393,0.0012853625,-0.0063072047,-0.01103087,-0.0034736795,-0.010390716,0.021913493,-0.021509185,0.0022085323,-0.003756695,0.009656223,0.016549673,0.0022186402,-0.020687092,-0.029056268,-0.00065447355,-0.0035309563,0.009305822,0.007958129,-0.0086387135,-0.02035017,-0.029298851,-0.007479698,-0.0205658,-0.0051178653,-0.003770172,-0.02394851,-0.020174969,0.010053792,-0.014325979,0.014811149,-0.0015481627,-0.0060073426,-0.0028116251,0.04091597,-0.026873004,0.00038851472,0.0037769105,0.017344812,-0.003067687,0.023099463,0.0015094165,-0.030296145,0.045012955,-0.035147842,-0.0067553124,0.0090025915,0.0063408967,0.020538846,-0.0011295355,0.0006153062,0.03870575,0.03840926,0.007486436,-0.040619474,-0.0059466967,0.033934917,0.018813798,0.026037434,0.0026195787,-0.010424407,0.011960777,-0.0032277254,0.007924437,0.011617116,-0.028328514,-0.024622357,0.0014639319,0.025147956,-0.00003919366,-0.008800437,-0.0345279,0.009757299,-0.003044102,0.023786787,0.008989114,-0.018207336,-0.0035612795,0.0025185018,-0.00079050637,-0.00048643304,0.0041778493,-0.00927213,-0.014285549,-0.018705983,-0.024150664,-0.021509185,-0.0032193023,0.028220698,-0.005720958,0.00070711784,-0.016953982,-0.0071629896,-0.02702125,0.0040093875,0.00628362,-0.0021411476,0.029110175,0.018220814,0.0071562515,0.022924263,0.0076144673,-0.002565671,0.0020771322,0.004016126,-0.007836836,0.0016509243,0.005485112,0.0061050504,-0.018988999,0.0060713585,-0.0017823244,0.0054413117,-0.0059837583,-0.0060342965,0.013348902,-0.0223178,-0.01300524,-0.013261302,-0.0058995276,0.030377006,-0.002319717,-0.02948753,0.0110982545,0.000072175295,-0.006657605,-0.031131715,0.00733819,-0.0033186947,-0.02649565,0.0060983123,0.011441916,-0.014555087,0.007291021,-0.017735643,0.03654944,0.024622357,0.0003013358,0.02227737,0.0105457,0.025026664,-0.0013965472,-0.012836779,-0.017803028,0.0021849477,0.025997004,0.00009791834,0.007048436,-0.00032555216,0.026131773,-0.025053618,0.01361844,-0.023517247,-0.0023230864,-0.014892011,0.016239705,0.022021309,-0.016967459,0.019056384,0.0047539882,0.0029598714,-0.0013519048,-0.0045585725,0.0015439511,0.021509185,-0.0050909114,0.029999653,0.00074712746,-0.011354316,-0.0037735412,0.0031805562,-0.0055962964,0.019298967,0.18652076,-0.010640038,0.0029514483,0.018962044,-0.0013190547,0.011852963,0.020444507,-0.004720296,0.0021344093,-0.0016542935,-0.008005298,0.013854287,0.0020181707,0.007210159,-0.0037162642,-0.0023129785,-0.03415055,-0.03202119,-0.023665493,0.012621148,0.00927213,-0.006630651,-0.007958129,-0.009379946,0.026172204,-0.006947359,-0.008679145,-0.0073516667,0.01739872,0.0014209741,-0.000361982,0.012142717,-0.0030036713,0.0080592055,-0.021873062,-0.0064116507,0.008227668,-0.028598052,0.0013156856,0.018476875,-0.014231641,0.010929792,0.0066373893,0.03840926,0.015565857,0.009777515,-0.0049628806,0.006920405,0.019528076,0.030646546,-0.028948452,-0.008335483,0.012412256,0.040942922,0.016482288,0.022021309,0.0041946955,0.0058759428,-0.011219546,-0.022021309,-0.016401427,0.020660138,-0.02632045,0.023355525,-0.018759891,0.014299026,-0.029406667,0.0076346826,0.019891953,-0.021387892,-0.0071629896,-0.014110349,-0.026684327,-0.004797788,-0.015606288,-0.006570005,0.034986116,0.006738466,-0.009838161,0.0011303778,-0.010538962,-0.03444704,0.00685639,-0.003888095,-0.009494499,-0.013800379,0.017236996,0.017614352,-0.017546967,0.017614352,0.0024612248,-0.0006982736,-0.008800437,0.0016677704,-0.004666388,-0.0050605885,0.018975522,0.009602315,-0.0034416718,-0.01401601,-0.018247766,-0.00032576272,0.005114496,0.009016068,-0.009609053,-0.0049662497,-0.001726732,0.0019339399,-0.010774808,-0.004016126,-0.0065127276,-0.018759891,0.0020063785,-0.0052661113,-0.0073449286,0.0017671628,-0.034905255,-0.014218165,0.004235126,-0.019649368,0.00010865777,-0.025727466,0.030781314,-0.00861176,-0.016158843,-0.016617058,-0.01454161,-0.0020333321,0.002092294,-0.032533314,0.006206128,-0.029433621,0.004663019,-0.023625063,-0.021199215,0.0073988363,0.007715544,0.00680922,-0.01103087,0.012270748,0.012614409,-0.034420088,-0.003898203,0.015848873,-0.0030828484,-0.0054244655,0.030107468,0.002491548,-0.009993146,-0.014824626,-0.026266541,-0.000074912794,-0.0048719114,-0.012277486,0.014770718,-0.021428322,-0.03506698,-0.013086102,-0.0028571098,0.024554972,-0.03439313,-0.010902839,0.04474342,-0.017196566,0.0026819096,0.00081240636,-0.17476887,0.004710188,0.024231525,-0.00033229063,0.025902664,0.027762482,0.008268098,0.00016561887,0.00027080212,0.0032934255,0.011799055,0.004161003,-0.037519783,0.007243851,-0.0018901399,-0.00799856,-0.024460632,0.008295052,-0.010821977,0.0101548685,0.017681736,0.0082748365,-0.008840868,-0.01722352,0.013793641,0.015983643,0.003409664,0.041589815,-0.010896101,0.0017722166,-0.03282981,-0.0031249637,0.02359811,0.01058613,-0.0003004935,-0.0016248127,-0.027924204,-0.016360996,-0.0048516956,0.014905488,0.0036724643,0.009063237,0.030781314,-0.023854172,-0.013706041,0.0202154,0.011340839,-0.013604964,0.013692563,-0.005879312,0.0024157402,0.0071764668,-0.01630709,0.0032850024,0.003343964,-0.00404308,0.012095547,-0.009898807,0.004764096,-0.0030744253,-0.031428207,-0.015821919,-0.0012407202,-0.024447156,-0.011718193,-0.013658872,-0.011542993,-0.0046832343,-0.0051347115,0.0032277254,0.004464234,-0.002718971,-0.0057613887,-0.016953982,0.01419121,0.0064891432,-0.012668317,0.0038914643,-0.0018193859,-0.004652911,-0.022910787,0.026953865,0.012890686,-0.009993146,-0.0041407878,-0.0024629096,-0.009541669,0.020687092,-0.015175027,-0.022735586,0.01485158,-0.029945744,-0.020377122,-0.010714161,0.008160283,0.010714161,-0.022439092,0.010330069,-0.016563151,-0.012836779,0.017439151,0.014258595,-0.029891837,0.00896216,0.03506698,0.005936589,0.02548488,0.0067283586,0.035821687,0.0056569427,0.005993866,0.028490236,0.011320624,0.021792201,0.012904163,0.025377065,0.007742498,0.01634752,0.016590104,0.01792432,0.04517468,0.0029935637,-0.019689798,0.0025892558,-0.0055524963,-0.0068867127,-0.10786937,-0.030484822,0.008146806,0.025916142,-0.0038375566,0.014918964,-0.0076481593,-0.003224356,-0.0068833437,0.010559177,-0.0007584986,-0.020242354,-0.021738293,-0.007884006,0.05703438,0.0015296319,-0.008706098,-0.01331521,-0.0153637035,0.03862489,-0.010437884,0.015121119,-0.0012070278,-0.007553821,-0.0088543445,-0.0060511427,-0.01349041,0.018220814,-0.018557737,-0.011987732,-0.012358348,-0.0053503425,-0.000028559516,-0.020148015,-0.011866439,-0.004289034,-0.010896101,-0.012412256,0.011482347,-0.0310239,0.01813995,0.03827449,-0.009406899,-0.022991648,0.009838161,-0.02262777,0.023678971,0.013375856,-0.009171053,-0.020094106,-0.01753349,-0.025188388,-0.03291067,0.0043463106,0.009689915,-0.00725059,0.0070147435,0.0063948045,-0.016940504,0.032991532,0.000852416,-0.002139463,-0.028948452,0.014689857,-0.0056434656,0.014299026,-0.013827333,-0.007958129,0.024864942,-0.0134836715,-0.018422967,0.013908194,-0.021037493,0.004336203,-0.03911006,-0.012627886,-0.019002475,0.0013670664,0.0411316,-0.009514715,-0.031455163,-0.020377122,0.0021647324,-0.01906986,0.027843343,0.018854229,-0.0076616365,0.0032614178,-0.000111395275,-0.010693946,-0.003945372,0.022209985,0.040349938,-0.03870575,0.008692621,0.02043103,0.0026044173,-0.019460691,-0.0032614178,0.010040315,-0.025026664,-0.0015102588,-0.047142312,0.043665264,-0.0054985886,-0.007243851,-0.0024831248,0.00084441405,0.025956573,-0.010889362,-0.00733819,0.018759891,-0.011866439,0.014959396,-0.008578068,0.0027206559,-0.025067095,-0.012499855,0.023180325,0.014865057,0.012452686,-0.0034905255,0.0030727407,-0.0048752804,0.028840637,0.01718309,-0.010444623,-0.020498415,-0.018921614,0.012392039,-0.0086387135,-0.0219674,0.024285434,-0.019083338,-0.013086102,0.01801866,0.02029626,-0.025471402,-0.011482347,0.0011126893,0.015754534,0.04846305,-0.026118295,-0.020336691,0.017075274,-0.007850314,0.014177733,0.030862177,0.007958129,0.018881183,0.013375856,0.001256724,0.006981051,0.028705867,-0.0033405947,-0.010309854,-0.020511892,-0.008254621,0.03695375,0.0015549011,0.024730172,0.0038375566,0.025740942,0.024528017,0.005171773,0.00013319,0.009588838,-0.0029733484,-0.004454126,-0.01199447,-0.012135978,-0.02830156,0.007958129,0.006859759,0.009110407,-0.005505327,-0.0067519434,0.005225681,0.011772101,0.014218165,-0.024878418,0.008955422,0.00900933,0.015094165,-0.038867474,0.018503828,0.012243793,0.012843517,-0.020727523,0.008193975,-0.013935149,0.014838103,0.012695271,0.0004902234,0.005950066,0.015929734,-0.006994528,0.021374416,-0.0093597295,-0.009440592,0.017749121,0.004908973,0.0036926796,-0.005458158,-0.00799856,-0.015646718,-0.008517422,0.0074729593,-0.012991764,-0.0061623277,-0.00944733,0.0032529947,0.013261302,-0.003827449,0.0026212635,0.0037769105,-0.0029143868,0.0013325317,0.0024797556,-0.005124604,-0.03989172,0.019568507,0.0100874845,0.016280135,-0.0003554541,-0.025565742,0.012560502,-0.010491792,0.008631975,-0.00904976,-0.00016856696,0.006010712,0.010781546,-0.0020670246,-0.021873062,-0.011859701,-0.00040346567,0.008665668,0.016199274,0.04204803,-0.036091227,0.032102056,0.02043103,0.008402867,0.013766687,-0.020201921,0.0054682656,-0.0037027872,-0.01221684,0.0030036713,-0.027573805,0.0054076193,0.001863186,-0.006357743,-0.029137129,-0.0096697,0.007675113,-0.0153637035,-0.014878534,0.0060612503,0.001300524,0.030484822,0.003800495,0.018908137,0.01840949,-0.00082461984,-0.030808268,0.014918964,-0.013254563,-0.0036050796,-0.009319299,-0.011920347,-0.0059062657,-0.020714046,-0.0051347115,0.02737165,0.005198727,-0.0059601734,-0.027519897,0.026967343,0.0007357563,0.010431146,0.017654782,-0.019797614,-0.039137013,0.033099346,0.0023129785,-0.011017392,-0.0032816331,-0.020848814], 7 "exact": true, 8 "limit": 10 9 } 10 }, 11 { 12 "$project": { 13 "_id": 0, 14 "plot": 1, 15 "title": 1, 16 "score": { $meta: "vectorSearchScore" } 17 } 18 } 19 ])
1 [ 2 { 3 plot: 'It is the dawn of World War III. In mid-western America, a group of teenagers bands together to defend their town, and their country, from invading Soviet forces.', 4 title: 'Red Dawn', 5 score: 0.7700583338737488 6 }, 7 { 8 plot: 'A dramatization of the World War II Battle of Iwo Jima.', 9 title: 'Sands of Iwo Jima', 10 score: 0.7581185102462769 11 }, 12 { 13 plot: 'Great Patriotic War, early 1940s. After barely surviving a battle with a mysterious, ghostly-white Tiger tank, Red Army Sergeant Ivan Naydenov becomes obsessed with its destruction.', 14 title: 'White Tiger', 15 score: 0.750884473323822 16 }, 17 { 18 plot: "As World War Two rages on, the allies are about to push the Nazis out of North Africa. That's when the Nazis turn up the heat, unleashing their secret Weapon - dragons.", 19 title: 'P-51 Dragon Fighter', 20 score: 0.749922513961792 21 }, 22 { 23 plot: 'A private in the latter days of WWII on the German front struggles between his will to survive and what his superiors perceive as a battlefield instinct.', 24 title: 'When Trumpets Fade', 25 score: 0.7498313188552856 26 }, 27 { 28 plot: 'Post World War III futuristic tale of collapsed governments & bankrupt countries heralding a new lawless age.', 29 title: 'Battletruck', 30 score: 0.7497193217277527 31 }, 32 { 33 plot: 'It is post-World War III. War is outlawed. In its place, are matches between large Robots called Robot Jox. These matches take place between two large superpowers over disputed territories....', 34 title: 'Robot Jox', 35 score: 0.7495121955871582 36 }, 37 { 38 plot: 'During World War II, an American destroyer meets a German U-Boat. Both captains are good ones, and the engagement lasts for a considerable time.', 39 title: 'The Enemy Below', 40 score: 0.746050238609314 41 }, 42 { 43 plot: 'Four American soldiers and one Brit fighting in Europe during World War II struggle to return to Allied territory after being separated from U.S. forces during the historic Malmedy Massacre.', 44 title: 'Saints and Soldiers', 45 score: 0.7435222864151001 46 }, 47 { 48 plot: 'Four American soldiers and one Brit fighting in Europe during World War II struggle to return to Allied territory after being separated from U.S. forces during the historic Malmedy Massacre.', 49 title: 'Saints and Soldiers', 50 score: 0.743497371673584 51 } 52 ]
Not yet available.
Not yet available.
1 const { MongoClient } = require("mongodb"); 2 3 // connect to your Atlas cluster 4 const uri = "<connection-string>"; 5 6 const client = new MongoClient(uri); 7 8 async function run() { 9 try { 10 await client.connect(); 11 12 // set namespace 13 const database = client.db("sample_mflix"); 14 const coll = database.collection("embedded_movies"); 15 16 // define pipeline 17 const agg = [ 18 { 19 '$vectorSearch': { 20 'index': 'vector_index', 21 'path': 'plot_embedding', 22 'queryVector': [ 23 -0.006954097,-0.009932499,-0.001311474,-0.021280076,-0.014608995,-0.008227668,-0.013274779,-0.0069271433,-0.009521453,-0.030943038,0.017304381,0.015094165,-0.010397454,0.010943269,0.012230316,0.025943095,0.02583528,0.001368751,0.009777515,-0.016024074,-0.013989056,0.00685639,0.030242238,-0.023881124,-0.011057823,-0.0056906347,-0.00055929273,-0.03199424,0.0072168973,-0.023166848,0.0033490178,-0.024069803,-0.023557678,-0.020862292,0.007452744,-0.019002475,0.007850314,-0.032856762,-0.012951332,0.003005356,-0.003739849,0.010053792,0.019541552,0.007702067,-0.035498243,-0.00918453,-0.0143529335,0.000249955,-0.011866439,0.019703276,0.0076481593,0.025161434,-0.015714103,-0.0076818517,-0.023180325,-0.0032883717,-0.02315337,0.015188503,0.031347346,-0.008739791,0.01454161,0.014824626,-0.025107525,0.0012558816,-0.012803086,-0.013146748,-0.01652272,0.01283004,-0.019352876,-0.010444623,0.04706145,0.030754361,0.008820653,0.011657547,0.014878534,-0.010181823,0.00041673204,-0.009103668,-0.0055255424,0.00579845,0.024110233,-0.020404076,-0.0066272817,-0.005299804,0.019649368,0.007729021,-0.0066845585,0.025592696,0.00575465,-0.014824626,0.00033334352,-0.008591545,0.004164372,0.028085928,-0.020875769,-0.00448108,-0.009258653,0.02535011,-0.0025538788,-0.059082873,-0.0074055744,0.005950066,-0.014164257,-0.016185796,-0.015768012,-0.01309284,0.0030222023,0.0028436328,0.0037095258,-0.0068462817,-0.010963485,0.018988999,0.010929792,-0.03967609,0.016994413,-0.023503771,-0.0037903874,-0.012075332,-0.005923112,-0.01902943,0.017978229,-0.005993866,0.024015894,-0.017722167,0.010875884,0.0153637035,-0.04045775,-0.0016568204,-0.0074190516,0.0011084777,0.033018485,0.021536138,0.025794849,-0.019622413,-0.041724585,0.014743765,-0.011111731,0.0065666353,-0.019851523,-0.035174794,0.007270805,0.02698082,-0.010929792,-0.020148015,-0.009689915,0.032182917,0.015700627,0.013786903,-0.0021647324,-0.0063644815,0.027317744,0.004403588,0.03158993,-0.0039116796,0.02029626,0.04191326,-0.0050504804,0.008416344,-0.0034602026,0.010485054,-0.0030996946,-0.0212666,0.0043934803,-0.016765304,-0.00039441086,0.025538787,0.008483729,0.017479582,-0.0061454815,-0.018220814,-0.0025589326,0.0102829,-0.045498125,0.029784022,0.017169613,0.020592753,0.012445947,0.021630477,-0.031050853,-0.011327362,-0.024689741,0.0048988652,0.022129124,0.0114621315,-0.026091343,0.015067211,0.004723665,0.017722167,0.014608995,-0.016805734,0.0042250184,0.027843343,0.03264113,0.007034959,-0.6852751,-0.019986292,0.003827449,0.0032462562,0.006115158,-0.001972686,0.001937309,0.015956689,-0.010437884,0.00803899,-0.01401601,-0.00026869634,-0.033207163,-0.00623982,-0.0048449575,-0.013193917,-0.00426208,-0.013207395,-0.014379887,0.017991705,0.0007264909,0.023517247,-0.00725059,0.0071832053,-0.003466941,-0.0072842822,0.0028234175,-0.02460888,0.0044608647,-0.008746529,-0.025713988,0.012499855,0.004882019,0.010525485,0.05250613,-0.003387764,-0.021212691,0.026549557,0.034123596,0.014325979,-0.0080592055,-0.012189886,-0.005970281,0.0115093,0.0021731553,0.033557564,0.020929677,-0.02130703,0.022991648,-0.03123953,0.0102829,-0.0067721587,0.008510683,0.010013361,0.031320393,0.010646777,0.015215457,-0.019797614,0.0022186402,-0.0010351969,0.0015523742,0.021630477,0.00751339,0.0062162355,-0.016468812,0.018840753,-0.02544445,0.030943038,0.008295052,-0.005700743,-0.0033557562,0.020053675,-0.012722225,-0.016778782,0.025511835,0.025538787,0.022802971,-0.017708689,-0.009615792,-0.00733819,0.0049224496,-0.021590047,-0.021158785,0.022034785,0.046872772,-0.021064445,-0.024811033,0.0043429416,-0.006169066,-0.0044406494,-0.003357441,0.006445343,-0.01801866,-0.0082074525,0.0037802798,0.02258734,0.0018598167,-0.0101548685,0.020134538,-0.008214191,-0.0004830638,0.00421828,0.0048719114,0.0087869605,-0.008335483,0.023503771,-0.030161375,0.0055929273,0.054069456,-0.010006622,0.018975522,0.015956689,-0.018530782,0.003669095,0.014662903,-0.023126416,0.011300408,0.021563092,-0.00106552,-0.03269504,0.020282784,-0.023665493,0.025242295,-0.01801866,-0.008537637,-0.00083472754,0.02130703,-0.008780221,0.0080592055,-0.0012971548,0.014838103,0.0056704194,0.015794965,0.001546478,0.013072625,0.0057310658,0.011711455,-0.020997062,0.010289638,0.0041070953,-0.025592696,0.012661578,-0.013436502,0.013348902,0.014312503,-0.023894602,-0.018517306,-0.0105928695,-0.02140137,0.0076885903,0.03220987,-0.0042283875,-0.04649542,-0.000022110593,0.00013803327,-0.0046293265,-0.0036286642,-0.028598052,-0.0042856648,-0.029406667,0.026765188,0.0027711943,-0.0059298505,-0.00311991,0.016293611,-0.027182974,-0.011623855,0.0030508407,-0.0035747564,-0.018032135,0.03045787,0.0011337469,-0.004780942,0.012055117,-0.0081333285,0.02908322,-0.008092898,-0.0015944897,0.014716811,0.014325979,-0.0037061565,-0.0074325283,-0.01854426,-0.0070821284,-0.003598341,-0.01718309,-0.0108826235,0.014959396,-0.019366352,0.017722167,0.009528192,0.022439092,-0.01630709,-0.003625295,-0.00413068,-0.007311236,-0.008503945,-0.006024189,0.038867474,0.030943038,0.015956689,0.007196682,0.013699302,0.0025471402,0.026792143,-0.031832516,-0.018867707,-0.03897529,0.04679191,0.00421828,0.01634752,-0.004120572,-0.009696653,-0.011414962,0.011980994,0.045659848,-0.010080745,-0.0045720492,-0.020794908,-0.0030205175,-0.00896216,-0.0071427743,0.006559897,0.0045147724,-0.032991532,0.0059332196,0.0033153256,0.00426208,0.0063779587,-0.025943095,-0.021495707,-0.008268098,-0.002429217,0.0102829,-0.0048786495,0.003584864,0.004737142,-0.029244944,0.027169496,0.010599608,-0.008517422,-0.0016652435,0.023544202,-0.022398662,0.010202038,0.0029211252,0.021185739,-0.01708875,-0.03396187,0.025121003,-0.009838161,0.015633242,-0.015525427,0.003743218,0.0044676033,-0.021819154,-0.006802482,-0.023126416,0.028112883,0.03045787,0.015255888,-0.008685883,-0.010943269,-0.0039386335,-0.0014950972,-0.009043022,-0.0023264554,-0.0028975406,-0.0021377786,0.002860479,-0.0010166661,-0.01173167,0.03040396,-0.028005067,-0.00509765,-0.008463514,0.019959338,-0.012533547,-0.012782871,-0.0055558654,0.004807896,-0.018800322,0.005582819,0.017991705,-0.005505327,-0.008382652,0.0011404854,-0.0035073718,-0.017587397,0.012890686,-0.0015363704,-0.000308706,0.011603639,-0.0042452337,-0.027129065,-0.0086387135,0.023786787,-0.024352817,-0.015175027,0.017546967,0.0064318664,0.0100874845,-0.008605022,-0.006529574,0.014703333,-0.0010318276,-0.012290963,-0.014622472,-0.008382652,-0.000661212,0.0044170646,0.009386684,-0.0030660022,0.0033102715,-0.007095605,0.007978344,-0.016980935,-0.0040262337,0.022344755,0.0077357595,0.0063341586,-0.016482288,-0.028220698,-0.026899958,0.08291009,0.014002534,0.00075428706,0.013018717,0.0013485356,-0.0223178,-0.016697919,-0.018584691,0.0057378043,0.007924437,0.0032850024,-0.01735829,0.029730113,0.021684386,-0.008382652,0.017021365,0.0030811639,-0.008025514,0.0043564187,-0.000044694985,-0.0038375566,-0.012924379,-0.012230316,0.0345279,-0.014689857,-0.019406782,0.008780221,0.0092923455,-0.01555238,-0.01920463,-0.01827472,-0.00305421,-0.017573921,0.016320566,0.02548488,0.02105097,0.012823301,0.03431227,0.026589988,-0.025606172,0.007755975,0.0019693167,0.0096494835,-0.034069687,0.0067721587,0.0004190484,0.005508696,0.033207163,-0.0011792317,-0.012648102,0.022829924,0.015821919,-0.035956457,-0.038732704,-0.020740999,0.0063880663,-0.010471577,-0.006933882,0.005936589,0.015889304,-0.00852416,-0.031455163,0.009305822,0.0051178653,-0.027452512,-0.015700627,-0.017762598,-0.005869204,-0.0065531586,-0.011879916,-0.008220929,-0.0053503425,-0.0026920172,-0.00038830412,0.019959338,-0.010444623,-0.00047548304,-0.015040257,0.0008330429,0.008005298,-0.0075336057,-0.02117226,-0.027250359,-0.018962044,-0.006138743,0.014918964,-0.014757241,-0.013867764,0.0006961678,0.01726395,-0.0039352644,0.005724327,0.019878477,0.009494499,0.0071832053,-0.0023652017,0.004865173,0.029784022,0.002390471,0.0005854043,0.00034387235,0.0053975116,-0.011650808,0.005218942,0.007136036,-0.0091440985,0.005879312,0.028193744,-0.024662787,-0.0029447097,0.009636007,-0.029730113,0.00025206077,0.006745205,0.011522777,0.02035017,0.026131773,0.029972699,0.008012037,-0.012466162,0.012459424,-0.01836906,0.0051515577,0.022196509,-0.015970165,0.0037465873,-0.008396129,-0.009494499,-0.0036657257,0.011219546,-0.01823429,0.013524102,0.015134595,0.020269306,-0.0028891175,0.008456775,0.0051650344,0.011131947,-0.0038948336,-0.010909577,-0.010485054,-0.026859527,-0.005475004,-0.0036589873,0.0034602026,-0.026253065,-0.010350284,0.0137734255,0.0030828484,0.012526809,-0.026131773,-0.02363854,0.00024321652,-0.015956689,-0.0042991415,-0.027762482,-0.012782871,-0.016940504,0.01256724,0.03598341,0.026387835,0.0013763318,0.0041946955,0.0017520012,-0.007755975,-0.011179116,0.003537695,0.011522777,-0.035929505,0.021037493,0.041859355,0.034770485,-0.012769394,0.0059534353,0.02851719,0.017749121,-0.011017392,0.0059568044,-0.02105097,-0.011233023,0.0095079765,-0.0019002475,-0.006472297,-0.00826136,-0.011495824,-0.024056325,0.00628362,0.0028689022,0.0050808038,0.00632742,0.020228876,-0.0029767177,0.0327759,-0.016859643,0.0006439447,-0.01516155,0.015889304,0.0032765793,-0.0017570552,0.016509242,0.0076481593,0.0033254332,-0.012513332,-0.0073718824,-0.012237055,0.025997004,-0.0052122036,-0.0007530236,-0.01739872,-0.020188445,-0.0005908793,-0.011212808,0.008840868,-0.015741058,0.0034197718,-0.0033456485,-0.010262684,0.010080745,-0.016751828,-0.04415043,0.010202038,0.0058557275,0.023369001,0.009238438,0.04029603,0.009743823,-0.006802482,-0.01502678,0.01634752,-0.018301675,0.011313885,0.030080514,0.009501237,0.000942543,-0.007755975,-0.015242411,0.003898203,-0.017236996,-0.026172204,0.02394851,0.0065834816,0.021617,0.0054514194,-0.039487414,-0.021549616,0.018813798,-0.025848757,0.0026566405,-0.011199331,-0.024635833,-0.01129367,0.010181823,-0.033638425,0.033072393,-0.008537637,-0.02597005,0.010444623,-0.037169382,-0.0003693522,0.008793699,-0.006647497,0.014716811,-0.026023958,-0.011455393,0.0012853625,-0.0063072047,-0.01103087,-0.0034736795,-0.010390716,0.021913493,-0.021509185,0.0022085323,-0.003756695,0.009656223,0.016549673,0.0022186402,-0.020687092,-0.029056268,-0.00065447355,-0.0035309563,0.009305822,0.007958129,-0.0086387135,-0.02035017,-0.029298851,-0.007479698,-0.0205658,-0.0051178653,-0.003770172,-0.02394851,-0.020174969,0.010053792,-0.014325979,0.014811149,-0.0015481627,-0.0060073426,-0.0028116251,0.04091597,-0.026873004,0.00038851472,0.0037769105,0.017344812,-0.003067687,0.023099463,0.0015094165,-0.030296145,0.045012955,-0.035147842,-0.0067553124,0.0090025915,0.0063408967,0.020538846,-0.0011295355,0.0006153062,0.03870575,0.03840926,0.007486436,-0.040619474,-0.0059466967,0.033934917,0.018813798,0.026037434,0.0026195787,-0.010424407,0.011960777,-0.0032277254,0.007924437,0.011617116,-0.028328514,-0.024622357,0.0014639319,0.025147956,-0.00003919366,-0.008800437,-0.0345279,0.009757299,-0.003044102,0.023786787,0.008989114,-0.018207336,-0.0035612795,0.0025185018,-0.00079050637,-0.00048643304,0.0041778493,-0.00927213,-0.014285549,-0.018705983,-0.024150664,-0.021509185,-0.0032193023,0.028220698,-0.005720958,0.00070711784,-0.016953982,-0.0071629896,-0.02702125,0.0040093875,0.00628362,-0.0021411476,0.029110175,0.018220814,0.0071562515,0.022924263,0.0076144673,-0.002565671,0.0020771322,0.004016126,-0.007836836,0.0016509243,0.005485112,0.0061050504,-0.018988999,0.0060713585,-0.0017823244,0.0054413117,-0.0059837583,-0.0060342965,0.013348902,-0.0223178,-0.01300524,-0.013261302,-0.0058995276,0.030377006,-0.002319717,-0.02948753,0.0110982545,0.000072175295,-0.006657605,-0.031131715,0.00733819,-0.0033186947,-0.02649565,0.0060983123,0.011441916,-0.014555087,0.007291021,-0.017735643,0.03654944,0.024622357,0.0003013358,0.02227737,0.0105457,0.025026664,-0.0013965472,-0.012836779,-0.017803028,0.0021849477,0.025997004,0.00009791834,0.007048436,-0.00032555216,0.026131773,-0.025053618,0.01361844,-0.023517247,-0.0023230864,-0.014892011,0.016239705,0.022021309,-0.016967459,0.019056384,0.0047539882,0.0029598714,-0.0013519048,-0.0045585725,0.0015439511,0.021509185,-0.0050909114,0.029999653,0.00074712746,-0.011354316,-0.0037735412,0.0031805562,-0.0055962964,0.019298967,0.18652076,-0.010640038,0.0029514483,0.018962044,-0.0013190547,0.011852963,0.020444507,-0.004720296,0.0021344093,-0.0016542935,-0.008005298,0.013854287,0.0020181707,0.007210159,-0.0037162642,-0.0023129785,-0.03415055,-0.03202119,-0.023665493,0.012621148,0.00927213,-0.006630651,-0.007958129,-0.009379946,0.026172204,-0.006947359,-0.008679145,-0.0073516667,0.01739872,0.0014209741,-0.000361982,0.012142717,-0.0030036713,0.0080592055,-0.021873062,-0.0064116507,0.008227668,-0.028598052,0.0013156856,0.018476875,-0.014231641,0.010929792,0.0066373893,0.03840926,0.015565857,0.009777515,-0.0049628806,0.006920405,0.019528076,0.030646546,-0.028948452,-0.008335483,0.012412256,0.040942922,0.016482288,0.022021309,0.0041946955,0.0058759428,-0.011219546,-0.022021309,-0.016401427,0.020660138,-0.02632045,0.023355525,-0.018759891,0.014299026,-0.029406667,0.0076346826,0.019891953,-0.021387892,-0.0071629896,-0.014110349,-0.026684327,-0.004797788,-0.015606288,-0.006570005,0.034986116,0.006738466,-0.009838161,0.0011303778,-0.010538962,-0.03444704,0.00685639,-0.003888095,-0.009494499,-0.013800379,0.017236996,0.017614352,-0.017546967,0.017614352,0.0024612248,-0.0006982736,-0.008800437,0.0016677704,-0.004666388,-0.0050605885,0.018975522,0.009602315,-0.0034416718,-0.01401601,-0.018247766,-0.00032576272,0.005114496,0.009016068,-0.009609053,-0.0049662497,-0.001726732,0.0019339399,-0.010774808,-0.004016126,-0.0065127276,-0.018759891,0.0020063785,-0.0052661113,-0.0073449286,0.0017671628,-0.034905255,-0.014218165,0.004235126,-0.019649368,0.00010865777,-0.025727466,0.030781314,-0.00861176,-0.016158843,-0.016617058,-0.01454161,-0.0020333321,0.002092294,-0.032533314,0.006206128,-0.029433621,0.004663019,-0.023625063,-0.021199215,0.0073988363,0.007715544,0.00680922,-0.01103087,0.012270748,0.012614409,-0.034420088,-0.003898203,0.015848873,-0.0030828484,-0.0054244655,0.030107468,0.002491548,-0.009993146,-0.014824626,-0.026266541,-0.000074912794,-0.0048719114,-0.012277486,0.014770718,-0.021428322,-0.03506698,-0.013086102,-0.0028571098,0.024554972,-0.03439313,-0.010902839,0.04474342,-0.017196566,0.0026819096,0.00081240636,-0.17476887,0.004710188,0.024231525,-0.00033229063,0.025902664,0.027762482,0.008268098,0.00016561887,0.00027080212,0.0032934255,0.011799055,0.004161003,-0.037519783,0.007243851,-0.0018901399,-0.00799856,-0.024460632,0.008295052,-0.010821977,0.0101548685,0.017681736,0.0082748365,-0.008840868,-0.01722352,0.013793641,0.015983643,0.003409664,0.041589815,-0.010896101,0.0017722166,-0.03282981,-0.0031249637,0.02359811,0.01058613,-0.0003004935,-0.0016248127,-0.027924204,-0.016360996,-0.0048516956,0.014905488,0.0036724643,0.009063237,0.030781314,-0.023854172,-0.013706041,0.0202154,0.011340839,-0.013604964,0.013692563,-0.005879312,0.0024157402,0.0071764668,-0.01630709,0.0032850024,0.003343964,-0.00404308,0.012095547,-0.009898807,0.004764096,-0.0030744253,-0.031428207,-0.015821919,-0.0012407202,-0.024447156,-0.011718193,-0.013658872,-0.011542993,-0.0046832343,-0.0051347115,0.0032277254,0.004464234,-0.002718971,-0.0057613887,-0.016953982,0.01419121,0.0064891432,-0.012668317,0.0038914643,-0.0018193859,-0.004652911,-0.022910787,0.026953865,0.012890686,-0.009993146,-0.0041407878,-0.0024629096,-0.009541669,0.020687092,-0.015175027,-0.022735586,0.01485158,-0.029945744,-0.020377122,-0.010714161,0.008160283,0.010714161,-0.022439092,0.010330069,-0.016563151,-0.012836779,0.017439151,0.014258595,-0.029891837,0.00896216,0.03506698,0.005936589,0.02548488,0.0067283586,0.035821687,0.0056569427,0.005993866,0.028490236,0.011320624,0.021792201,0.012904163,0.025377065,0.007742498,0.01634752,0.016590104,0.01792432,0.04517468,0.0029935637,-0.019689798,0.0025892558,-0.0055524963,-0.0068867127,-0.10786937,-0.030484822,0.008146806,0.025916142,-0.0038375566,0.014918964,-0.0076481593,-0.003224356,-0.0068833437,0.010559177,-0.0007584986,-0.020242354,-0.021738293,-0.007884006,0.05703438,0.0015296319,-0.008706098,-0.01331521,-0.0153637035,0.03862489,-0.010437884,0.015121119,-0.0012070278,-0.007553821,-0.0088543445,-0.0060511427,-0.01349041,0.018220814,-0.018557737,-0.011987732,-0.012358348,-0.0053503425,-0.000028559516,-0.020148015,-0.011866439,-0.004289034,-0.010896101,-0.012412256,0.011482347,-0.0310239,0.01813995,0.03827449,-0.009406899,-0.022991648,0.009838161,-0.02262777,0.023678971,0.013375856,-0.009171053,-0.020094106,-0.01753349,-0.025188388,-0.03291067,0.0043463106,0.009689915,-0.00725059,0.0070147435,0.0063948045,-0.016940504,0.032991532,0.000852416,-0.002139463,-0.028948452,0.014689857,-0.0056434656,0.014299026,-0.013827333,-0.007958129,0.024864942,-0.0134836715,-0.018422967,0.013908194,-0.021037493,0.004336203,-0.03911006,-0.012627886,-0.019002475,0.0013670664,0.0411316,-0.009514715,-0.031455163,-0.020377122,0.0021647324,-0.01906986,0.027843343,0.018854229,-0.0076616365,0.0032614178,-0.000111395275,-0.010693946,-0.003945372,0.022209985,0.040349938,-0.03870575,0.008692621,0.02043103,0.0026044173,-0.019460691,-0.0032614178,0.010040315,-0.025026664,-0.0015102588,-0.047142312,0.043665264,-0.0054985886,-0.007243851,-0.0024831248,0.00084441405,0.025956573,-0.010889362,-0.00733819,0.018759891,-0.011866439,0.014959396,-0.008578068,0.0027206559,-0.025067095,-0.012499855,0.023180325,0.014865057,0.012452686,-0.0034905255,0.0030727407,-0.0048752804,0.028840637,0.01718309,-0.010444623,-0.020498415,-0.018921614,0.012392039,-0.0086387135,-0.0219674,0.024285434,-0.019083338,-0.013086102,0.01801866,0.02029626,-0.025471402,-0.011482347,0.0011126893,0.015754534,0.04846305,-0.026118295,-0.020336691,0.017075274,-0.007850314,0.014177733,0.030862177,0.007958129,0.018881183,0.013375856,0.001256724,0.006981051,0.028705867,-0.0033405947,-0.010309854,-0.020511892,-0.008254621,0.03695375,0.0015549011,0.024730172,0.0038375566,0.025740942,0.024528017,0.005171773,0.00013319,0.009588838,-0.0029733484,-0.004454126,-0.01199447,-0.012135978,-0.02830156,0.007958129,0.006859759,0.009110407,-0.005505327,-0.0067519434,0.005225681,0.011772101,0.014218165,-0.024878418,0.008955422,0.00900933,0.015094165,-0.038867474,0.018503828,0.012243793,0.012843517,-0.020727523,0.008193975,-0.013935149,0.014838103,0.012695271,0.0004902234,0.005950066,0.015929734,-0.006994528,0.021374416,-0.0093597295,-0.009440592,0.017749121,0.004908973,0.0036926796,-0.005458158,-0.00799856,-0.015646718,-0.008517422,0.0074729593,-0.012991764,-0.0061623277,-0.00944733,0.0032529947,0.013261302,-0.003827449,0.0026212635,0.0037769105,-0.0029143868,0.0013325317,0.0024797556,-0.005124604,-0.03989172,0.019568507,0.0100874845,0.016280135,-0.0003554541,-0.025565742,0.012560502,-0.010491792,0.008631975,-0.00904976,-0.00016856696,0.006010712,0.010781546,-0.0020670246,-0.021873062,-0.011859701,-0.00040346567,0.008665668,0.016199274,0.04204803,-0.036091227,0.032102056,0.02043103,0.008402867,0.013766687,-0.020201921,0.0054682656,-0.0037027872,-0.01221684,0.0030036713,-0.027573805,0.0054076193,0.001863186,-0.006357743,-0.029137129,-0.0096697,0.007675113,-0.0153637035,-0.014878534,0.0060612503,0.001300524,0.030484822,0.003800495,0.018908137,0.01840949,-0.00082461984,-0.030808268,0.014918964,-0.013254563,-0.0036050796,-0.009319299,-0.011920347,-0.0059062657,-0.020714046,-0.0051347115,0.02737165,0.005198727,-0.0059601734,-0.027519897,0.026967343,0.0007357563,0.010431146,0.017654782,-0.019797614,-0.039137013,0.033099346,0.0023129785,-0.011017392,-0.0032816331,-0.020848814 24 ], 25 'exact': true, 26 'limit': 10 27 } 28 }, { 29 '$project': { 30 '_id': 0, 31 'plot': 1, 32 'title': 1, 33 'score': { 34 '$meta': 'vectorSearchScore' 35 } 36 } 37 } 38 ]; 39 // run pipeline 40 const result = coll.aggregate(agg); 41 42 // print results 43 await result.forEach((doc) => console.dir(JSON.stringify(doc))); 44 } finally { 45 await client.close(); 46 } 47 } 48 run().catch(console.dir);
1 { 2 "plot":"It is the dawn of World War III. In mid-western America, a group of teenagers bands together to defend their town, and their country, from invading Soviet forces.", 3 "title":"Red Dawn", 4 "score":0.7700583338737488 5 } 6 { 7 "plot":"A dramatization of the World War II Battle of Iwo Jima.", 8 "title":"Sands of Iwo Jima", 9 "score":0.7581185102462769 10 } 11 { 12 "plot":"Great Patriotic War, early 1940s. After barely surviving a battle with a mysterious, ghostly-white Tiger tank, Red Army Sergeant Ivan Naydenov becomes obsessed with its destruction.", 13 "title":"White Tiger", 14 "score":0.750884473323822 15 } 16 { 17 "plot":"As World War Two rages on, the allies are about to push the Nazis out of North Africa. That's when the Nazis turn up the heat, unleashing their secret Weapon - dragons.", 18 "title":"P-51 Dragon Fighter", 19 "score":0.749922513961792 20 } 21 { 22 "plot":"A private in the latter days of WWII on the German front struggles between his will to survive and what his superiors perceive as a battlefield instinct.", 23 "title":"When Trumpets Fade", 24 "score":0.7498313188552856 25 } 26 { 27 "plot":"Post World War III futuristic tale of collapsed governments & bankrupt countries heralding a new lawless age.", 28 "title":"Battletruck", 29 "score":0.7497193217277527 30 } 31 { 32 "plot":"It is post-World War III. War is outlawed. In its place, are matches between large Robots called Robot Jox. These matches take place between two large superpowers over disputed territories....", 33 "title":"Robot Jox", 34 "score":0.7495121955871582 35 } 36 { 37 "plot":"During World War II, an American destroyer meets a German U-Boat. Both captains are good ones, and the engagement lasts for a considerable time.", 38 "title":"The Enemy Below", 39 "score":0.746050238609314 40 } 41 { 42 "plot":"Four American soldiers and one Brit fighting in Europe during World War II struggle to return to Allied territory after being separated from U.S. forces during the historic Malmedy Massacre.", 43 "title":"Saints and Soldiers", 44 "score":0.7435222864151001 45 } 46 { 47 "plot":"Four American soldiers and one Brit fighting in Europe during World War II struggle to return to Allied territory after being separated from U.S. forces during the historic Malmedy Massacre.", 48 "title":"Saints and Soldiers", 49 "score":0.743497371673584 50 }
1 import pymongo 2 import datetime 3 4 # connect to your Atlas cluster 5 client = pymongo.MongoClient("<connection-string>") 6 7 # define pipeline 8 pipeline = [ 9 { 10 '$vectorSearch': { 11 'index': 'vector_index', 12 'path': 'plot_embedding', 13 'queryVector': [-0.006954097,-0.009932499,-0.001311474,-0.021280076,-0.014608995,-0.008227668,-0.013274779,-0.0069271433,-0.009521453,-0.030943038,0.017304381,0.015094165,-0.010397454,0.010943269,0.012230316,0.025943095,0.02583528,0.001368751,0.009777515,-0.016024074,-0.013989056,0.00685639,0.030242238,-0.023881124,-0.011057823,-0.0056906347,-0.00055929273,-0.03199424,0.0072168973,-0.023166848,0.0033490178,-0.024069803,-0.023557678,-0.020862292,0.007452744,-0.019002475,0.007850314,-0.032856762,-0.012951332,0.003005356,-0.003739849,0.010053792,0.019541552,0.007702067,-0.035498243,-0.00918453,-0.0143529335,0.000249955,-0.011866439,0.019703276,0.0076481593,0.025161434,-0.015714103,-0.0076818517,-0.023180325,-0.0032883717,-0.02315337,0.015188503,0.031347346,-0.008739791,0.01454161,0.014824626,-0.025107525,0.0012558816,-0.012803086,-0.013146748,-0.01652272,0.01283004,-0.019352876,-0.010444623,0.04706145,0.030754361,0.008820653,0.011657547,0.014878534,-0.010181823,0.00041673204,-0.009103668,-0.0055255424,0.00579845,0.024110233,-0.020404076,-0.0066272817,-0.005299804,0.019649368,0.007729021,-0.0066845585,0.025592696,0.00575465,-0.014824626,0.00033334352,-0.008591545,0.004164372,0.028085928,-0.020875769,-0.00448108,-0.009258653,0.02535011,-0.0025538788,-0.059082873,-0.0074055744,0.005950066,-0.014164257,-0.016185796,-0.015768012,-0.01309284,0.0030222023,0.0028436328,0.0037095258,-0.0068462817,-0.010963485,0.018988999,0.010929792,-0.03967609,0.016994413,-0.023503771,-0.0037903874,-0.012075332,-0.005923112,-0.01902943,0.017978229,-0.005993866,0.024015894,-0.017722167,0.010875884,0.0153637035,-0.04045775,-0.0016568204,-0.0074190516,0.0011084777,0.033018485,0.021536138,0.025794849,-0.019622413,-0.041724585,0.014743765,-0.011111731,0.0065666353,-0.019851523,-0.035174794,0.007270805,0.02698082,-0.010929792,-0.020148015,-0.009689915,0.032182917,0.015700627,0.013786903,-0.0021647324,-0.0063644815,0.027317744,0.004403588,0.03158993,-0.0039116796,0.02029626,0.04191326,-0.0050504804,0.008416344,-0.0034602026,0.010485054,-0.0030996946,-0.0212666,0.0043934803,-0.016765304,-0.00039441086,0.025538787,0.008483729,0.017479582,-0.0061454815,-0.018220814,-0.0025589326,0.0102829,-0.045498125,0.029784022,0.017169613,0.020592753,0.012445947,0.021630477,-0.031050853,-0.011327362,-0.024689741,0.0048988652,0.022129124,0.0114621315,-0.026091343,0.015067211,0.004723665,0.017722167,0.014608995,-0.016805734,0.0042250184,0.027843343,0.03264113,0.007034959,-0.6852751,-0.019986292,0.003827449,0.0032462562,0.006115158,-0.001972686,0.001937309,0.015956689,-0.010437884,0.00803899,-0.01401601,-0.00026869634,-0.033207163,-0.00623982,-0.0048449575,-0.013193917,-0.00426208,-0.013207395,-0.014379887,0.017991705,0.0007264909,0.023517247,-0.00725059,0.0071832053,-0.003466941,-0.0072842822,0.0028234175,-0.02460888,0.0044608647,-0.008746529,-0.025713988,0.012499855,0.004882019,0.010525485,0.05250613,-0.003387764,-0.021212691,0.026549557,0.034123596,0.014325979,-0.0080592055,-0.012189886,-0.005970281,0.0115093,0.0021731553,0.033557564,0.020929677,-0.02130703,0.022991648,-0.03123953,0.0102829,-0.0067721587,0.008510683,0.010013361,0.031320393,0.010646777,0.015215457,-0.019797614,0.0022186402,-0.0010351969,0.0015523742,0.021630477,0.00751339,0.0062162355,-0.016468812,0.018840753,-0.02544445,0.030943038,0.008295052,-0.005700743,-0.0033557562,0.020053675,-0.012722225,-0.016778782,0.025511835,0.025538787,0.022802971,-0.017708689,-0.009615792,-0.00733819,0.0049224496,-0.021590047,-0.021158785,0.022034785,0.046872772,-0.021064445,-0.024811033,0.0043429416,-0.006169066,-0.0044406494,-0.003357441,0.006445343,-0.01801866,-0.0082074525,0.0037802798,0.02258734,0.0018598167,-0.0101548685,0.020134538,-0.008214191,-0.0004830638,0.00421828,0.0048719114,0.0087869605,-0.008335483,0.023503771,-0.030161375,0.0055929273,0.054069456,-0.010006622,0.018975522,0.015956689,-0.018530782,0.003669095,0.014662903,-0.023126416,0.011300408,0.021563092,-0.00106552,-0.03269504,0.020282784,-0.023665493,0.025242295,-0.01801866,-0.008537637,-0.00083472754,0.02130703,-0.008780221,0.0080592055,-0.0012971548,0.014838103,0.0056704194,0.015794965,0.001546478,0.013072625,0.0057310658,0.011711455,-0.020997062,0.010289638,0.0041070953,-0.025592696,0.012661578,-0.013436502,0.013348902,0.014312503,-0.023894602,-0.018517306,-0.0105928695,-0.02140137,0.0076885903,0.03220987,-0.0042283875,-0.04649542,-0.000022110593,0.00013803327,-0.0046293265,-0.0036286642,-0.028598052,-0.0042856648,-0.029406667,0.026765188,0.0027711943,-0.0059298505,-0.00311991,0.016293611,-0.027182974,-0.011623855,0.0030508407,-0.0035747564,-0.018032135,0.03045787,0.0011337469,-0.004780942,0.012055117,-0.0081333285,0.02908322,-0.008092898,-0.0015944897,0.014716811,0.014325979,-0.0037061565,-0.0074325283,-0.01854426,-0.0070821284,-0.003598341,-0.01718309,-0.0108826235,0.014959396,-0.019366352,0.017722167,0.009528192,0.022439092,-0.01630709,-0.003625295,-0.00413068,-0.007311236,-0.008503945,-0.006024189,0.038867474,0.030943038,0.015956689,0.007196682,0.013699302,0.0025471402,0.026792143,-0.031832516,-0.018867707,-0.03897529,0.04679191,0.00421828,0.01634752,-0.004120572,-0.009696653,-0.011414962,0.011980994,0.045659848,-0.010080745,-0.0045720492,-0.020794908,-0.0030205175,-0.00896216,-0.0071427743,0.006559897,0.0045147724,-0.032991532,0.0059332196,0.0033153256,0.00426208,0.0063779587,-0.025943095,-0.021495707,-0.008268098,-0.002429217,0.0102829,-0.0048786495,0.003584864,0.004737142,-0.029244944,0.027169496,0.010599608,-0.008517422,-0.0016652435,0.023544202,-0.022398662,0.010202038,0.0029211252,0.021185739,-0.01708875,-0.03396187,0.025121003,-0.009838161,0.015633242,-0.015525427,0.003743218,0.0044676033,-0.021819154,-0.006802482,-0.023126416,0.028112883,0.03045787,0.015255888,-0.008685883,-0.010943269,-0.0039386335,-0.0014950972,-0.009043022,-0.0023264554,-0.0028975406,-0.0021377786,0.002860479,-0.0010166661,-0.01173167,0.03040396,-0.028005067,-0.00509765,-0.008463514,0.019959338,-0.012533547,-0.012782871,-0.0055558654,0.004807896,-0.018800322,0.005582819,0.017991705,-0.005505327,-0.008382652,0.0011404854,-0.0035073718,-0.017587397,0.012890686,-0.0015363704,-0.000308706,0.011603639,-0.0042452337,-0.027129065,-0.0086387135,0.023786787,-0.024352817,-0.015175027,0.017546967,0.0064318664,0.0100874845,-0.008605022,-0.006529574,0.014703333,-0.0010318276,-0.012290963,-0.014622472,-0.008382652,-0.000661212,0.0044170646,0.009386684,-0.0030660022,0.0033102715,-0.007095605,0.007978344,-0.016980935,-0.0040262337,0.022344755,0.0077357595,0.0063341586,-0.016482288,-0.028220698,-0.026899958,0.08291009,0.014002534,0.00075428706,0.013018717,0.0013485356,-0.0223178,-0.016697919,-0.018584691,0.0057378043,0.007924437,0.0032850024,-0.01735829,0.029730113,0.021684386,-0.008382652,0.017021365,0.0030811639,-0.008025514,0.0043564187,-0.000044694985,-0.0038375566,-0.012924379,-0.012230316,0.0345279,-0.014689857,-0.019406782,0.008780221,0.0092923455,-0.01555238,-0.01920463,-0.01827472,-0.00305421,-0.017573921,0.016320566,0.02548488,0.02105097,0.012823301,0.03431227,0.026589988,-0.025606172,0.007755975,0.0019693167,0.0096494835,-0.034069687,0.0067721587,0.0004190484,0.005508696,0.033207163,-0.0011792317,-0.012648102,0.022829924,0.015821919,-0.035956457,-0.038732704,-0.020740999,0.0063880663,-0.010471577,-0.006933882,0.005936589,0.015889304,-0.00852416,-0.031455163,0.009305822,0.0051178653,-0.027452512,-0.015700627,-0.017762598,-0.005869204,-0.0065531586,-0.011879916,-0.008220929,-0.0053503425,-0.0026920172,-0.00038830412,0.019959338,-0.010444623,-0.00047548304,-0.015040257,0.0008330429,0.008005298,-0.0075336057,-0.02117226,-0.027250359,-0.018962044,-0.006138743,0.014918964,-0.014757241,-0.013867764,0.0006961678,0.01726395,-0.0039352644,0.005724327,0.019878477,0.009494499,0.0071832053,-0.0023652017,0.004865173,0.029784022,0.002390471,0.0005854043,0.00034387235,0.0053975116,-0.011650808,0.005218942,0.007136036,-0.0091440985,0.005879312,0.028193744,-0.024662787,-0.0029447097,0.009636007,-0.029730113,0.00025206077,0.006745205,0.011522777,0.02035017,0.026131773,0.029972699,0.008012037,-0.012466162,0.012459424,-0.01836906,0.0051515577,0.022196509,-0.015970165,0.0037465873,-0.008396129,-0.009494499,-0.0036657257,0.011219546,-0.01823429,0.013524102,0.015134595,0.020269306,-0.0028891175,0.008456775,0.0051650344,0.011131947,-0.0038948336,-0.010909577,-0.010485054,-0.026859527,-0.005475004,-0.0036589873,0.0034602026,-0.026253065,-0.010350284,0.0137734255,0.0030828484,0.012526809,-0.026131773,-0.02363854,0.00024321652,-0.015956689,-0.0042991415,-0.027762482,-0.012782871,-0.016940504,0.01256724,0.03598341,0.026387835,0.0013763318,0.0041946955,0.0017520012,-0.007755975,-0.011179116,0.003537695,0.011522777,-0.035929505,0.021037493,0.041859355,0.034770485,-0.012769394,0.0059534353,0.02851719,0.017749121,-0.011017392,0.0059568044,-0.02105097,-0.011233023,0.0095079765,-0.0019002475,-0.006472297,-0.00826136,-0.011495824,-0.024056325,0.00628362,0.0028689022,0.0050808038,0.00632742,0.020228876,-0.0029767177,0.0327759,-0.016859643,0.0006439447,-0.01516155,0.015889304,0.0032765793,-0.0017570552,0.016509242,0.0076481593,0.0033254332,-0.012513332,-0.0073718824,-0.012237055,0.025997004,-0.0052122036,-0.0007530236,-0.01739872,-0.020188445,-0.0005908793,-0.011212808,0.008840868,-0.015741058,0.0034197718,-0.0033456485,-0.010262684,0.010080745,-0.016751828,-0.04415043,0.010202038,0.0058557275,0.023369001,0.009238438,0.04029603,0.009743823,-0.006802482,-0.01502678,0.01634752,-0.018301675,0.011313885,0.030080514,0.009501237,0.000942543,-0.007755975,-0.015242411,0.003898203,-0.017236996,-0.026172204,0.02394851,0.0065834816,0.021617,0.0054514194,-0.039487414,-0.021549616,0.018813798,-0.025848757,0.0026566405,-0.011199331,-0.024635833,-0.01129367,0.010181823,-0.033638425,0.033072393,-0.008537637,-0.02597005,0.010444623,-0.037169382,-0.0003693522,0.008793699,-0.006647497,0.014716811,-0.026023958,-0.011455393,0.0012853625,-0.0063072047,-0.01103087,-0.0034736795,-0.010390716,0.021913493,-0.021509185,0.0022085323,-0.003756695,0.009656223,0.016549673,0.0022186402,-0.020687092,-0.029056268,-0.00065447355,-0.0035309563,0.009305822,0.007958129,-0.0086387135,-0.02035017,-0.029298851,-0.007479698,-0.0205658,-0.0051178653,-0.003770172,-0.02394851,-0.020174969,0.010053792,-0.014325979,0.014811149,-0.0015481627,-0.0060073426,-0.0028116251,0.04091597,-0.026873004,0.00038851472,0.0037769105,0.017344812,-0.003067687,0.023099463,0.0015094165,-0.030296145,0.045012955,-0.035147842,-0.0067553124,0.0090025915,0.0063408967,0.020538846,-0.0011295355,0.0006153062,0.03870575,0.03840926,0.007486436,-0.040619474,-0.0059466967,0.033934917,0.018813798,0.026037434,0.0026195787,-0.010424407,0.011960777,-0.0032277254,0.007924437,0.011617116,-0.028328514,-0.024622357,0.0014639319,0.025147956,-0.00003919366,-0.008800437,-0.0345279,0.009757299,-0.003044102,0.023786787,0.008989114,-0.018207336,-0.0035612795,0.0025185018,-0.00079050637,-0.00048643304,0.0041778493,-0.00927213,-0.014285549,-0.018705983,-0.024150664,-0.021509185,-0.0032193023,0.028220698,-0.005720958,0.00070711784,-0.016953982,-0.0071629896,-0.02702125,0.0040093875,0.00628362,-0.0021411476,0.029110175,0.018220814,0.0071562515,0.022924263,0.0076144673,-0.002565671,0.0020771322,0.004016126,-0.007836836,0.0016509243,0.005485112,0.0061050504,-0.018988999,0.0060713585,-0.0017823244,0.0054413117,-0.0059837583,-0.0060342965,0.013348902,-0.0223178,-0.01300524,-0.013261302,-0.0058995276,0.030377006,-0.002319717,-0.02948753,0.0110982545,0.000072175295,-0.006657605,-0.031131715,0.00733819,-0.0033186947,-0.02649565,0.0060983123,0.011441916,-0.014555087,0.007291021,-0.017735643,0.03654944,0.024622357,0.0003013358,0.02227737,0.0105457,0.025026664,-0.0013965472,-0.012836779,-0.017803028,0.0021849477,0.025997004,0.00009791834,0.007048436,-0.00032555216,0.026131773,-0.025053618,0.01361844,-0.023517247,-0.0023230864,-0.014892011,0.016239705,0.022021309,-0.016967459,0.019056384,0.0047539882,0.0029598714,-0.0013519048,-0.0045585725,0.0015439511,0.021509185,-0.0050909114,0.029999653,0.00074712746,-0.011354316,-0.0037735412,0.0031805562,-0.0055962964,0.019298967,0.18652076,-0.010640038,0.0029514483,0.018962044,-0.0013190547,0.011852963,0.020444507,-0.004720296,0.0021344093,-0.0016542935,-0.008005298,0.013854287,0.0020181707,0.007210159,-0.0037162642,-0.0023129785,-0.03415055,-0.03202119,-0.023665493,0.012621148,0.00927213,-0.006630651,-0.007958129,-0.009379946,0.026172204,-0.006947359,-0.008679145,-0.0073516667,0.01739872,0.0014209741,-0.000361982,0.012142717,-0.0030036713,0.0080592055,-0.021873062,-0.0064116507,0.008227668,-0.028598052,0.0013156856,0.018476875,-0.014231641,0.010929792,0.0066373893,0.03840926,0.015565857,0.009777515,-0.0049628806,0.006920405,0.019528076,0.030646546,-0.028948452,-0.008335483,0.012412256,0.040942922,0.016482288,0.022021309,0.0041946955,0.0058759428,-0.011219546,-0.022021309,-0.016401427,0.020660138,-0.02632045,0.023355525,-0.018759891,0.014299026,-0.029406667,0.0076346826,0.019891953,-0.021387892,-0.0071629896,-0.014110349,-0.026684327,-0.004797788,-0.015606288,-0.006570005,0.034986116,0.006738466,-0.009838161,0.0011303778,-0.010538962,-0.03444704,0.00685639,-0.003888095,-0.009494499,-0.013800379,0.017236996,0.017614352,-0.017546967,0.017614352,0.0024612248,-0.0006982736,-0.008800437,0.0016677704,-0.004666388,-0.0050605885,0.018975522,0.009602315,-0.0034416718,-0.01401601,-0.018247766,-0.00032576272,0.005114496,0.009016068,-0.009609053,-0.0049662497,-0.001726732,0.0019339399,-0.010774808,-0.004016126,-0.0065127276,-0.018759891,0.0020063785,-0.0052661113,-0.0073449286,0.0017671628,-0.034905255,-0.014218165,0.004235126,-0.019649368,0.00010865777,-0.025727466,0.030781314,-0.00861176,-0.016158843,-0.016617058,-0.01454161,-0.0020333321,0.002092294,-0.032533314,0.006206128,-0.029433621,0.004663019,-0.023625063,-0.021199215,0.0073988363,0.007715544,0.00680922,-0.01103087,0.012270748,0.012614409,-0.034420088,-0.003898203,0.015848873,-0.0030828484,-0.0054244655,0.030107468,0.002491548,-0.009993146,-0.014824626,-0.026266541,-0.000074912794,-0.0048719114,-0.012277486,0.014770718,-0.021428322,-0.03506698,-0.013086102,-0.0028571098,0.024554972,-0.03439313,-0.010902839,0.04474342,-0.017196566,0.0026819096,0.00081240636,-0.17476887,0.004710188,0.024231525,-0.00033229063,0.025902664,0.027762482,0.008268098,0.00016561887,0.00027080212,0.0032934255,0.011799055,0.004161003,-0.037519783,0.007243851,-0.0018901399,-0.00799856,-0.024460632,0.008295052,-0.010821977,0.0101548685,0.017681736,0.0082748365,-0.008840868,-0.01722352,0.013793641,0.015983643,0.003409664,0.041589815,-0.010896101,0.0017722166,-0.03282981,-0.0031249637,0.02359811,0.01058613,-0.0003004935,-0.0016248127,-0.027924204,-0.016360996,-0.0048516956,0.014905488,0.0036724643,0.009063237,0.030781314,-0.023854172,-0.013706041,0.0202154,0.011340839,-0.013604964,0.013692563,-0.005879312,0.0024157402,0.0071764668,-0.01630709,0.0032850024,0.003343964,-0.00404308,0.012095547,-0.009898807,0.004764096,-0.0030744253,-0.031428207,-0.015821919,-0.0012407202,-0.024447156,-0.011718193,-0.013658872,-0.011542993,-0.0046832343,-0.0051347115,0.0032277254,0.004464234,-0.002718971,-0.0057613887,-0.016953982,0.01419121,0.0064891432,-0.012668317,0.0038914643,-0.0018193859,-0.004652911,-0.022910787,0.026953865,0.012890686,-0.009993146,-0.0041407878,-0.0024629096,-0.009541669,0.020687092,-0.015175027,-0.022735586,0.01485158,-0.029945744,-0.020377122,-0.010714161,0.008160283,0.010714161,-0.022439092,0.010330069,-0.016563151,-0.012836779,0.017439151,0.014258595,-0.029891837,0.00896216,0.03506698,0.005936589,0.02548488,0.0067283586,0.035821687,0.0056569427,0.005993866,0.028490236,0.011320624,0.021792201,0.012904163,0.025377065,0.007742498,0.01634752,0.016590104,0.01792432,0.04517468,0.0029935637,-0.019689798,0.0025892558,-0.0055524963,-0.0068867127,-0.10786937,-0.030484822,0.008146806,0.025916142,-0.0038375566,0.014918964,-0.0076481593,-0.003224356,-0.0068833437,0.010559177,-0.0007584986,-0.020242354,-0.021738293,-0.007884006,0.05703438,0.0015296319,-0.008706098,-0.01331521,-0.0153637035,0.03862489,-0.010437884,0.015121119,-0.0012070278,-0.007553821,-0.0088543445,-0.0060511427,-0.01349041,0.018220814,-0.018557737,-0.011987732,-0.012358348,-0.0053503425,-0.000028559516,-0.020148015,-0.011866439,-0.004289034,-0.010896101,-0.012412256,0.011482347,-0.0310239,0.01813995,0.03827449,-0.009406899,-0.022991648,0.009838161,-0.02262777,0.023678971,0.013375856,-0.009171053,-0.020094106,-0.01753349,-0.025188388,-0.03291067,0.0043463106,0.009689915,-0.00725059,0.0070147435,0.0063948045,-0.016940504,0.032991532,0.000852416,-0.002139463,-0.028948452,0.014689857,-0.0056434656,0.014299026,-0.013827333,-0.007958129,0.024864942,-0.0134836715,-0.018422967,0.013908194,-0.021037493,0.004336203,-0.03911006,-0.012627886,-0.019002475,0.0013670664,0.0411316,-0.009514715,-0.031455163,-0.020377122,0.0021647324,-0.01906986,0.027843343,0.018854229,-0.0076616365,0.0032614178,-0.000111395275,-0.010693946,-0.003945372,0.022209985,0.040349938,-0.03870575,0.008692621,0.02043103,0.0026044173,-0.019460691,-0.0032614178,0.010040315,-0.025026664,-0.0015102588,-0.047142312,0.043665264,-0.0054985886,-0.007243851,-0.0024831248,0.00084441405,0.025956573,-0.010889362,-0.00733819,0.018759891,-0.011866439,0.014959396,-0.008578068,0.0027206559,-0.025067095,-0.012499855,0.023180325,0.014865057,0.012452686,-0.0034905255,0.0030727407,-0.0048752804,0.028840637,0.01718309,-0.010444623,-0.020498415,-0.018921614,0.012392039,-0.0086387135,-0.0219674,0.024285434,-0.019083338,-0.013086102,0.01801866,0.02029626,-0.025471402,-0.011482347,0.0011126893,0.015754534,0.04846305,-0.026118295,-0.020336691,0.017075274,-0.007850314,0.014177733,0.030862177,0.007958129,0.018881183,0.013375856,0.001256724,0.006981051,0.028705867,-0.0033405947,-0.010309854,-0.020511892,-0.008254621,0.03695375,0.0015549011,0.024730172,0.0038375566,0.025740942,0.024528017,0.005171773,0.00013319,0.009588838,-0.0029733484,-0.004454126,-0.01199447,-0.012135978,-0.02830156,0.007958129,0.006859759,0.009110407,-0.005505327,-0.0067519434,0.005225681,0.011772101,0.014218165,-0.024878418,0.008955422,0.00900933,0.015094165,-0.038867474,0.018503828,0.012243793,0.012843517,-0.020727523,0.008193975,-0.013935149,0.014838103,0.012695271,0.0004902234,0.005950066,0.015929734,-0.006994528,0.021374416,-0.0093597295,-0.009440592,0.017749121,0.004908973,0.0036926796,-0.005458158,-0.00799856,-0.015646718,-0.008517422,0.0074729593,-0.012991764,-0.0061623277,-0.00944733,0.0032529947,0.013261302,-0.003827449,0.0026212635,0.0037769105,-0.0029143868,0.0013325317,0.0024797556,-0.005124604,-0.03989172,0.019568507,0.0100874845,0.016280135,-0.0003554541,-0.025565742,0.012560502,-0.010491792,0.008631975,-0.00904976,-0.00016856696,0.006010712,0.010781546,-0.0020670246,-0.021873062,-0.011859701,-0.00040346567,0.008665668,0.016199274,0.04204803,-0.036091227,0.032102056,0.02043103,0.008402867,0.013766687,-0.020201921,0.0054682656,-0.0037027872,-0.01221684,0.0030036713,-0.027573805,0.0054076193,0.001863186,-0.006357743,-0.029137129,-0.0096697,0.007675113,-0.0153637035,-0.014878534,0.0060612503,0.001300524,0.030484822,0.003800495,0.018908137,0.01840949,-0.00082461984,-0.030808268,0.014918964,-0.013254563,-0.0036050796,-0.009319299,-0.011920347,-0.0059062657,-0.020714046,-0.0051347115,0.02737165,0.005198727,-0.0059601734,-0.027519897,0.026967343,0.0007357563,0.010431146,0.017654782,-0.019797614,-0.039137013,0.033099346,0.0023129785,-0.011017392,-0.0032816331,-0.020848814], 14 'exact': True, 15 'limit': 10 16 } 17 }, { 18 '$project': { 19 '_id': 0, 20 'plot': 1, 21 'title': 1, 22 'score': { 23 '$meta': 'vectorSearchScore' 24 } 25 } 26 } 27 ] 28 29 # run pipeline 30 result = client["sample_mflix"]["embedded_movies"].aggregate(pipeline) 31 32 # print results 33 for i in result: 34 print(i) 35
1 { 2 'plot': 'It is the dawn of World War III. In mid-western America, a group of teenagers bands together to defend their town, and their country, from invading Soviet forces.', 3 'title': 'Red Dawn', 4 'score': 0.7700583338737488 5 } 6 { 7 'plot': 'A dramatization of the World War II Battle of Iwo Jima.', 8 'title': 'Sands of Iwo Jima', 9 'score': 0.7581185102462769 10 } 11 { 12 'plot': 'Great Patriotic War, early 1940s. After barely surviving a battle with a mysterious, ghostly-white Tiger tank, Red Army Sergeant Ivan Naydenov becomes obsessed with its destruction.', 13 'title': 'White Tiger', 14 'score': 0.750884473323822 15 } 16 { 17 'plot': "As World War Two rages on, the allies are about to push the Nazis out of North Africa. That's when the Nazis turn up the heat, unleashing their secret Weapon - dragons.", 18 'title': 'P-51 Dragon Fighter', 19 'score': 0.749922513961792 20 } 21 { 22 'plot': 'A private in the latter days of WWII on the German front struggles between his will to survive and what his superiors perceive as a battlefield instinct.', 23 'title': 'When Trumpets Fade', 24 'score': 0.7498313188552856 25 } 26 { 27 'plot': 'Post World War III futuristic tale of collapsed governments & bankrupt countries heralding a new lawless age.', 28 'score': 0.7497193217277527 29 } 30 { 31 'plot': 'It is post-World War III. War is outlawed. In its place, are matches between large Robots called Robot Jox. These matches take place between two large superpowers over disputed territories....', 32 'title': 'Robot Jox', 33 'score': 0.7495121955871582 34 } 35 { 36 'plot': 'During World War II, an American destroyer meets a German U-Boat. Both captains are good ones, and the engagement lasts for a considerable time.', 37 'title': 'The Enemy Below', 38 'score': 0.746050238609314} 39 {'plot': 'Four American soldiers and one Brit fighting in Europe during World War II struggle to return to Allied territory after being separated from U.S. forces during the historic Malmedy Massacre.', 'title': 'Saints and Soldiers', 'score': 0.7435222864151001 40 } 41 { 42 'plot': 'Four American soldiers and one Brit fighting in Europe during World War II struggle to return to Allied territory after being separated from U.S. forces during the historic Malmedy Massacre.', 43 'title': 'Saints and Soldiers', 44 'score': 0.743497371673584 45 }