Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/
Atlas
/ /

MongoDB Vector Search 및 MongoDB Search로 하이브리드 검색 수행

이 튜토리얼에서는 동일한 쿼리 조건에 대해 전체 텍스트 검색과 시맨틱 검색을 집계한 하이브리드 검색을 시연합니다. 전체 텍스트 검색은 쿼리 텀에 대한 정확한 일치를 찾는 데 효과적인 반면, 시맨틱 검색은 문서에 정확한 쿼리 텀이 포함되어 있지 않더라도 의미적으로 유사한 문서를 식별할 수 있는 추가 이점을 제공합니다. 이를 통해 동의어나 맥락적으로 유사한 결과도 두 검색 방법을 결합한 결과에 포함될 수 있습니다.

반대로 데이터 세트에 고유 명사나 특정 키워드에 대한 토큰이 포함되어 있다면 이러한 토큰이 데이터 세트에서 사용되는 동일한 맥락에서 임베딩 모델의 학습에 고려되지 않기를 원할 수 있습니다. 이 경우 벡터 검색을 전체 텍스트 검색과 결합하면 더 나은 결과를 얻을 수 있습니다.

또한 쿼리별로 각 검색 방법에 대한 가중치를 설정할 수 있습니다. 전체 텍스트 또는 시맨틱 검색 결과가 쿼리에 가장 관련성이 높고 적절한지 여부에 따라, 쿼리별로 해당 검색 방법의 가중치를 높일 수 있습니다.

이 튜토리얼에서는 영화에 대한 세부 정보가 포함된 sample_mflix.embedded_movies 컬렉션 에서 MongoDB Vector Search와 MongoDB Search 쿼리를 결합한 하이브리드 검색 실행 통합 검색 결과를 얻는 방법을 보여 줍니다. 구체적으로 이 튜토리얼에서는 다음 단계를 안내합니다.

  1. plot_embedding_voyage_3_large 필드 에 MongoDB Vector Search 인덱스 생성합니다. 이 필드 에는 영화 줄거리의 요약을 나타내는 벡터 임베딩이 포함됩니다.

  2. sample_mflix.embedded_movies 컬렉션 의 title 필드 에 MongoDB Search 인덱스 만듭니다. 이 필드 에는 영화 이름이 텍스트 문자열로 포함됩니다.

  3. 상호 순위 결합을 사용하여 plot_embedding_voyage_3_large 필드에 대한 $vectorSearch 쿼리와 title 필드에 대한 $search 쿼리의 결과를 결합하는 쿼리를 실행합니다.

시작하기 전에 공통 전제 조건을 완료합니다.Project Data Access Admin MongoDB Vector Search 및 MongoDB Search 인덱스를 생성하려면 프로젝트 에 대한 액세스 있어야 합니다.

이 섹션에서는 sample_mflix.embedded_movies collection의 필드에 다음 인덱스를 생성하는 방법을 보여 줍니다.

  • 해당 필드 에 대해 벡터 쿼리를 실행 위한 plot_embedding_voyage_3_large 필드 에 대한 MongoDB Vector Search 인덱스 .

  • 해당 필드 에 대해 전체 텍스트 검색 실행 위한 title 필드 에 대한 MongoDB Search 인덱스 .

1

자세한 학습은 mongosh 통해 클러스터에 연결을참조하세요.

2
use sample_mflix
switched to db sample_mflix
3

다음 명령을 실행합니다. 이 인덱스 정의는 컬렉션 을 쿼리할 때 plot_embedding_voyage_3_large 필드 MongoDB Vector Search 필드 로 인덱싱합니다.

1db.embedded_movies.createSearchIndex(
2 "hybrid-vector-search",
3 "vectorSearch",
4 {
5 "fields": [
6 {
7 "type": "vector",
8 "path": "plot_embedding_voyage_3_large",
9 "numDimensions": 2048,
10 "similarity": "dotProduct"
11 }
12 ]
13 }
14);
4

다음 인덱스 정의는 컬렉션 에서 동적으로 인덱싱할 수 있는 모든 필드를 자동으로 인덱싱합니다.

1db.embedded_movies.createSearchIndex(
2 "hybrid-full-text-search",
3 "search",
4 {
5 "mappings": {
6 "dynamic": true
7 }
8 }
9);

이 섹션에서는 단계 내의 $vectorSearch 및 파이프라인 단계를 사용하여 다시 정렬하여 및 $search 필드에서 스타 워즈에 대한 컬렉션 sample_mflix.embedded_movies 의 데이터를 plot_embedding_voyage_3_large title 쿼리 방법을 보여 $rankFusion 줍니다. 결과에 문서가 표시됩니다. 단계는 $rankFusion 두 검색에 모두 나타나는 문서가 결합된 결과의 상단에 나타나도록 합니다.

1
  1. query-embeddings.js이라는 파일을 만듭니다.

  2. 다음 임베딩을 복사하여 파일 에 붙여넣습니다.

    STAR_WARS_EMBEDDING=[-0.025189938,0.014741838,-0.013024342,-0.0197512,0.011235285,0.004651551,0.043509893,0.003112961,0.013310592,-0.033348043,0.037212405,-0.021039322,-0.026048684,0.012809656,0.029483676,0.003578116,-0.044654887,0.032632418,0.014312465,-0.058967352,0.025333062,-0.055246111,0.02189807,-0.017604331,-0.002880384,0.045227386,0.004794675,0.017604331,0.023186192,-0.054673612,-0.011306847,-0.012523406,-0.012380281,0.002540462,0.015958399,-0.042364895,-0.001467028,-0.020180576,-0.058108605,-0.035065539,0.010090288,-0.033348043,0.058394853,-0.013883091,0.002048471,-0.020753073,-0.029769925,0.031916797,-0.014741838,-0.040933646,-0.004096943,0.020753073,-0.002540462,0.028052431,-0.02404494,0.006547953,-0.003578116,0.003757022,0.019178702,-0.037784904,-0.02833868,0.01753277,0.029769925,0.017747456,-0.031344298,0.022899942,0.006333265,0.010376536,-0.024474313,-0.012094032,-0.004651551,0.007764512,0.017962143,0.013811528,0.037212405,-0.03148742,0.000666424,0.024474313,-0.021325571,0.041219898,0.011235285,0.046658635,0.019035578,0.020753073,0.010662786,-0.001726441,-0.012738093,-0.027193682,-0.014598713,-0.013167467,0.013596841,0.001932183,-0.010304974,-0.007478263,0.005689205,0.002987727,0.005724986,0.002325775,0.002415228,-0.003828584,-0.029340552,-0.017318081,-0.070417322,0.003810694,-0.013453716,-0.001628043,-0.027909305,0.014026215,0.009589351,0.004902019,0.028768053,-0.005259831,-0.010448099,0.025189938,0.038357403,0.048662379,0.039788652,0.010448099,0.001574371,0.020323699,0.005510299,0.026907433,0.043223642,-0.001153942,-0.010233412,0.048376128,-0.056104861,0.006691077,0.015672149,-0.015028087,0.036210533,-0.009231539,0.010519661,0.022899942,0.025762435,-0.009052633,-0.0301993,0.032203045,-0.00522405,0.029626802,-0.02433119,-0.025619311,0.016674021,0.02404494,-0.009589351,-0.026334934,-0.04436864,-0.014455589,0.02619181,0.017604331,0.02189807,-0.007728731,-0.021611821,-0.03363429,0.008480135,-0.027479932,0.025046812,-0.006047016,0.020753073,0.01016185,-0.034063663,0.029483676,-0.019035578,0.041506145,0.013453716,-0.009159978,0.007549825,0.025189938,0.005152487,-0.009446226,-0.009016853,0.021325571,0.030771798,-0.046944883,0.001314958,0.021182448,0.047231134,-0.007048889,-0.030771798,-0.025905561,-0.000612752,-0.023186192,0.011378409,0.035065539,0.007979199,0.023901815,-0.004973582,0.005188268,-0.046944883,0.009374664,0.047231134,0.058967352,0.043509893,0.011449971,0.017174957,-0.024188064,-0.025476186,-0.02833868,0.033061791,0.015314337,-0.018749328,0.013382155,0.007048889,0.005975454,0.005295612,-0.013310592,-0.022756819,-0.012523406,-0.03363429,-0.014527151,0.011449971,0.01202247,0.044941138,-0.012594969,0.002862493,0.000572499,0.030628674,-0.0098756,0.020466823,0.059539851,-0.00370335,0.007335138,0.023901815,0.023758691,-0.005903892,0.003918037,0.013310592,0.010090288,-0.012809656,-0.010376536,-0.01109216,-0.008086543,0.012809656,-0.019894326,0.012738093,0.056391109,0.029340552,-0.04436864,-0.001619098,0.042364895,-0.027623056,0.011593096,-0.031916797,-0.0301993,0.032203045,-0.003757022,0.017174957,0.033491168,0.003900147,0.002325775,0.006726858,0.020180576,0.017389644,0.009088415,0.018319955,-0.003631788,0.00586811,-0.006691077,-0.014240902,-0.009052633,0.031630546,0.04436864,-0.022899942,-0.003327648,-0.006691077,0.013310592,-0.035924286,-0.008158104,-0.005116706,-0.040647399,0.002397338,0.014455589,-0.030342424,0.028624929,-0.031773672,0.043509893,-0.001833785,-0.025619311,0.032775544,-0.046944883,0.013739966,-0.030485548,0.018319955,0.016745584,-0.020323699,-0.015815273,-0.020896198,-0.015171212,0.026334934,0.035638034,0.008873728,0.003291867,-0.02647806,0.003649678,0.003613897,0.009804038,-0.013525278,0.005367174,0.007657168,-0.017103394,-0.015815273,-0.000398065,0.013310592,0.014240902,0.003935928,0.001735386,-0.018606203,0.008265448,-0.068127327,0.012165595,-0.007836075,0.02189807,-0.000983982,0.019178702,-0.009589351,-0.013739966,-0.007800293,0.040361151,0.027623056,-0.002540462,-0.03663991,0.011163722,-0.016316209,-0.006333265,-0.010877473,-0.023329318,-0.021468697,0.013596841,0.032059919,0.007442481,0.02433119,-0.003613897,-0.013596841,0.010448099,0.010877473,-0.0098756,0.033920541,-0.006691077,-0.039502401,-0.010877473,-0.016960271,0.014097777,-0.008122323,0.007478263,0.010018725,-0.030485548,-0.011020597,0.000317558,0.00461577,0.020466823,0.070703574,-0.024617439,0.002111088,-0.024617439,-0.004204286,-0.048662379,-0.006834202,0.027766181,-0.002504681,0.025189938,0.033920541,-0.02833868,-0.000773768,-0.03578116,0.015958399,0.006369046,0.033204917,-0.006762639,0.02003745,-0.020180576,0.015886836,-0.015385899,-0.029340552,-0.009446226,0.015529023,-0.010376536,-0.012881218,-0.000715623,0.014312465,-0.029197427,-0.000684315,0.000360048,0.015815273,-0.027050557,0.006655296,0.018892452,-0.021182448,0.031201173,0.014240902,-0.022756819,0.004365302,-0.020609949,0.008515916,-0.016244646,0.001162888,0.000084421,0.003273976,-0.017819017,0.000576971,0.020753073,-0.004794675,0.018105267,-0.013095905,-0.028052431,0.004114834,0.02833868,-0.027193682,-0.010877473,-0.002576244,0.011879345,-0.017819017,0.006726858,-0.021754947,-0.031773672,-0.013382155,0.024903689,0.013167467,0.000033964,0.034063663,0.022613693,-0.038357403,-0.010018725,-0.017174957,-0.004418973,0.02189807,-0.003166633,-0.009589351,0.009303101,-0.036496785,-0.005760767,-0.006583733,-0.003596007,0.014026215,-0.003828584,-0.02833868,-0.020896198,0.001449137,0.039502401,0.012881218,0.025476186,0.000961619,-0.025762435,0.002808821,0.034922414,0.004687332,-0.046658635,0.030914923,-0.036067411,0.008659041,-0.004025381,-0.0301993,-0.026048684,0.024760563,0.036496785,-0.029913051,0.015672149,0.007764512,0.01509965,0.010304974,-0.004490536,-0.007585606,-0.019464951,0.016602458,-0.007048889,-0.005510299,0.011163722,0.013739966,-0.034636162,0.020609949,-0.004418973,0.034636162,0.040933646,0.031773672,0.023758691,0.031344298,-0.006798421,0.026048684,-0.011521534,0.020753073,0.014384027,0.026334934,-0.034206789,-0.036067411,0.014598713,0.023758691,-0.039216153,0.003363429,0.002880384,-0.006726858,-0.000916892,-0.001395465,-0.009660914,0.032059919,0.008086543,0.029054303,-0.011593096,0.065551087,0.031058047,-0.041219898,-0.014097777,-0.017103394,0.016244646,-0.028911177,0.044654887,-0.030771798,0.024760563,0.02833868,0.018248392,0.026907433,-0.002227377,0.034063663,0.000167724,0.021039322,-0.018892452,0.012738093,-0.001395465,0.005760767,-0.024760563,-0.002683587,0.000230341,-0.0197512,0.009088415,-0.00400749,-0.026764309,-0.012881218,0.016101522,-0.009303101,0.015529023,-0.016817145,0.014312465,-0.030914923,-0.018463079,0.020323699,-0.023472441,-0.023758691,-0.005009362,0.018176829,0.012738093,0.009374664,-0.031916797,0.016387772,0.027479932,0.015529023,-0.021325571,0.020323699,-0.025476186,0.008515916,-0.039788652,-0.007979199,-0.009947163,-0.006869983,0.004758894,0.022613693,-0.013668403,-0.015171212,0.035351787,-0.022327444,0.019178702,0.000404774,-0.003524444,-0.012094032,0.023901815,-0.0400749,-0.004579989,0.00245101,0.013024342,0.015958399,0.009517789,0.034779288,0.021468697,0.00062617,0.007728731,-0.028195554,0.0301993,-0.002504681,0.008909509,0.004651551,-0.007013108,0.03148742,0.019608077,0.002540462,0.043509893,-0.006190141,0.024903689,0.010519661,0.018319955,0.010519661,0.009660914,0.000966091,-0.004454754,0.000299667,0.007907636,-0.018463079,0.004758894,-0.001851675,-0.002415228,0.010233412,-0.024617439,-0.030771798,0.018749328,0.003023508,0.005474518,-0.011521534,-0.008551697,0.007979199,0.03363429,0.000275068,0.007800293,0.0039896,0.00522405,-0.035924286,-0.01416934,0.02619181,-0.025476186,-0.033777416,0.021325571,-0.02218432,0.001833785,0.027766181,-0.006118578,0.032059919,0.038929902,0.003613897,0.031344298,-0.002737259,0.057536107,0.009732476,0.020753073,0.005402955,-0.047803629,-0.040933646,0.009052633,-0.030485548,0.018319955,0.025046812,-0.002361557,0.045513637,0.008766385,-0.031058047,0.014312465,0.002737259,-0.004186396,0.032059919,0.024617439,-0.012666531,0.006798421,0.02619181,-0.012523406,0.009947163,0.005617642,0.039216153,0.008766385,0.009517789,0.042651143,-0.012881218,0.007263576,-0.000514354,0.016817145,-0.048948627,0.018176829,0.034922414,0.005331393,0.000391356,-0.017604331,0.026048684,-0.011807784,0.017461207,0.012809656,0.029483676,-0.017174957,0.023472441,0.005188268,0.007585606,-0.034922414,0.069558576,0.023472441,-0.010304974,0.020180576,0.025046812,0.016459335,0.000317558,-0.018606203,0.066696085,0.011664659,0.025762435,-0.016888708,0.015314337,-0.009231539,0.016459335,-0.021325571,0.009303101,0.000840857,-0.014455589,0.00170855,0.014741838,-0.004168505,-0.009088415,-0.0074067,-0.004472645,0.002665696,0.023615567,0.038929902,-0.016960271,-0.027193682,0.03663991,-0.016530896,0.003256086,0.015171212,0.036926158,0.02433119,0.047231134,-0.049234878,0.009947163,-0.01109216,-0.014097777,-0.007585606,0.00338132,-0.008086543,0.018176829,-0.014527151,-0.000205742,-0.041219898,0.012666531,0.046086136,0.004025381,-0.0074067,0.033348043,-0.020896198,-0.000514354,0.033491168,0.004257958,0.02404494,-0.008372792,-0.021754947,0.037784904,0.013453716,0.013024342,-0.026334934,0.023758691,0.012094032,0.006297485,0.045227386,0.021039322,-0.020323699,0.005975454,0.008802165,0.00370335,0.006941545,-0.029340552,-0.008551697,-0.004454754,0.003488663,0.010662786,0.00801498,0.010090288,0.015600586,0.018105267,-0.020180576,-0.00307718,0.031630546,0.000644061,0.011950907,-0.023472441,0.01509965,-0.035924286,0.016459335,-0.027766181,-0.014598713,-0.021611821,-0.013310592,-0.021039322,-0.02189807,0.018606203,-0.007979199,0.018176829,0.022041194,-0.002916165,0.009088415,-0.00522405,-0.018176829,-0.031916797,-0.017318081,-0.025476186,-0.014527151,-0.017675893,-0.026621183,0.000362284,0.02619181,0.016101522,-0.013310592,0.021325571,0.027909305,0.016316209,0.006011235,0.008551697,0.030914923,-0.070703574,0.004794675,-0.019321827,-0.011163722,-0.014598713,-0.0197512,-0.005438737,-0.025189938,-0.037212405,0.004168505,-0.021754947,0.018033706,0.035065539,0.022756819,0.005581861,-0.007764512,-0.003005618,-0.003524444,0.006655296,-0.00170855,-0.046086136,-0.009374664,0.001744332,0.030056175,0.016674021,0.014312465,0.029054303,-0.009052633,0.005832329,-0.029197427,-0.004723113,0.032489292,0.022899942,-0.044941138,0.014026215,-0.007227794,-0.035494912,0.001261286,0.079004802,0.008122323,0.022041194,0.016602458,0.046658635,-0.016888708,-0.006547953,-0.016316209,0.002021636,-0.016745584,0.003792803,0.005116706,-0.037784904,-0.028481804,-0.014670276,-0.005259831,0.018892452,0.001252341,-0.068699829,-0.021611821,-0.015242774,-0.027050557,-0.032059919,0.026048684,-0.014240902,-0.007013108,0.014598713,-0.005474518,-0.007192013,-0.016817145,0.00400749,0.010519661,0.007657168,0.005295612,0.009124196,0.024474313,-0.019894326,-0.044941138,-0.022756819,-0.022327444,-0.041792396,0.027479932,-0.013668403,-0.036210533,0.001225505,0.009947163,-0.044654887,-0.02003745,0.031344298,-0.004186396,-0.009517789,0.000720096,-0.023901815,0.000670897,0.022899942,0.006619515,0.006512171,0.022327444,0.021468697,0.021611821,0.039216153,-0.019608077,0.028052431,-0.020466823,-0.0197512,0.004454754,0.026048684,-0.024617439,-0.000333212,0.002200541,-0.002629915,0.021611821,0.009374664,0.00894529,-0.057822354,-0.009660914,-0.002844602,0.020323699,0.000603807,0.018033706,-0.027050557,-0.004186396,-0.019608077,-0.021754947,0.009732476,0.01602996,-0.016960271,-0.001520699,-0.023615567,0.004383192,0.000925838,0.023043068,0.032775544,0.006404828,-0.010304974,0.019321827,0.017604331,-0.01230872,0.007657168,0.005402955,-0.03148742,-0.000550135,-0.002111088,-0.029626802,0.01323903,-0.033777416,0.006655296,0.035065539,-0.003256086,0.000907947,0.004025381,0.011020597,-0.04808988,0.02619181,0.015171212,0.023758691,0.014741838,-0.001359684,-0.041506145,-0.009088415,-0.012738093,0.000176669,0.033777416,0.024188064,-0.002307885,0.023901815,0.00034663,-0.024474313,-0.031773672,-0.023758691,-0.024474313,-0.011163722,0.000447265,0.005080925,-0.00123445,0.006297485,-0.031058047,-0.012738093,-0.003059289,-0.026907433,-0.015672149,-0.005760767,0.023043068,0.023043068,-0.015028087,0.017747456,0.013883091,-0.011807784,0.038357403,-0.016817145,0.014884963,0.017389644,-0.000599334,0.016602458,0.008086543,-0.039502401,0.050379876,-0.024474313,0.035351787,-0.023758691,0.002039526,0.004061162,-0.012165595,-0.020180576,0.001636988,-0.013883091,0.017389644,0.006225922,-0.03578116,-0.016817145,-0.001332848,-0.005617642,-0.008730603,-0.039216153,0.02433119,0.028052431,0.02833868,0.039502401,0.010233412,-0.006869983,0.021468697,0.002039526,-0.0197512,0.020753073,0.027050557,0.009517789,0.011449971,0.038929902,0.008873728,0.009374664,0.007871855,-0.006082797,-0.007156232,-0.014670276,-0.000447265,0.046944883,-0.015242774,-0.019894326,0.008158104,0.016173085,-0.018463079,0.034922414,-0.005009362,-0.000092248,0.005760767,0.006190141,-0.022613693,0.034206789,0.012523406,0.000992927,0.038071156,-0.048376128,-0.017747456,0.014384027,0.000751404,0.015314337,-0.010519661,0.058681104,0.013954652,0.022899942,-0.003757022,0.01416934,-0.000469628,-0.008337011,-0.001153942,0.02189807,-0.024760563,0.01416934,-0.012738093,-0.025046812,0.030771798,-0.046658635,-0.002137924,0.053242367,0.010090288,-0.046086136,0.016316209,-0.005295612,0.023043068,-0.023043068,0.010233412,-0.018319955,-0.017389644,0.030485548,0.009660914,0.017174957,0.050379876,-0.010304974,0.017819017,-0.000364521,0.011163722,0.001753277,0.010448099,0.013095905,0.008372792,-0.01109216,0.036926158,-0.015672149,-0.014598713,0.008981071,-0.011879345,-0.036926158,-0.01789058,-0.008694822,-0.028911177,-0.017103394,-0.028768053,-0.030914923,0.001033181,0.00431163,-0.024474313,-0.031058047,0.010018725,0.00647639,-0.027336806,0.025046812,0.003148742,-0.010018725,0.03663991,0.033348043,-0.001162888,-0.01016185,0.010376536,0.010519661,0.019178702,0.016101522,0.007943418,-0.013739966,-0.013525278,-0.027193682,0.006655296,0.027050557,-0.017389644,-0.027479932,0.041792396,0.045513637,-0.014741838,0.012451844,0.018319955,-0.00153859,0.010519661,0.017962143,-0.012594969,0.018606203,0.023472441,-0.034063663,-0.004061162,0.015600586,0.019178702,0.002361557,-0.025619311,-0.00586811,-0.02003745,0.013739966,0.017675893,-0.025189938,-0.002415228,0.001547535,0.019608077,0.039502401,-0.00184273,0.025189938,0.00277304,0.020323699,0.007227794,0.012165595,-0.00370335,0.02433119,-0.00586811,0.016459335,0.034206789,0.001051072,-0.010519661,-0.004096943,0.00153859,0.01574371,0.01230872,-0.007692949,-0.019464951,0.005116706,0.017389644,0.024903689,0.046658635,-0.010519661,0.020609949,0.060684849,-0.045227386,-0.008551697,-0.004293739,-0.001502809,-0.015815273,-0.005975454,0.000290722,0.027050557,-0.002245268,-0.016888708,-0.027193682,-0.001288122,-0.021182448,-0.041219898,0.031916797,0.030628674,-0.03234617,0.006655296,0.008372792,-0.009016853,-0.033348043,0.010877473,-0.05238362,-0.004490536,-0.028911177,0.006905764,-0.003506554,0.039788652,-0.036496785,-0.015886836,0.015314337,-0.015672149,0.006225922,-0.021182448,-0.034349915,-0.043223642,-0.025476186,0.002558353,0.007048889,-0.037784904,-0.014026215,-0.044654887,-0.036926158,0.008229667,0.007728731,0.039216153,-0.00027954,0.026907433,0.027193682,-0.017174957,-0.011378409,0.017174957,-0.015815273,0.009446226,0.033777416,-0.014384027,0.003721241,-0.024760563,-0.000229223,0.008802165,-0.000377939,-0.007692949,0.016173085,0.018248392,-0.02218432,-0.003202414,-0.033204917,-0.002969836,-0.023186192,0.030056175,-0.015457462,-0.015314337,-0.008981071,0.022613693,-0.014026215,-0.025476186,0.025333062,0.034206789,0.010662786,0.016387772,0.030342424,-0.008086543,0.007120451,0.000221396,0.025619311,0.01789058,-0.008086543,0.011807784,-0.016101522,0.002719368,0.005653423,0.017962143,-0.001941128,0.06297484,0.016244646,0.003524444,0.018749328,-0.001815894,0.006082797,0.069558576,-0.011020597,0.018033706,0.026621183,0.007692949,-0.008694822,0.035924286,-0.001878511,-0.005975454,-0.028911177,-0.007871855,0.014741838,0.008587479,0.026621183,0.005259831,-0.023186192,0.000368993,-0.01323903,0.002683587,-0.011306847,0.007478263,-0.000621698,0.022756819,-0.018892452,-0.013167467,0.007764512,-0.010877473,-0.017461207,-0.013525278,0.014240902,-0.019464951,-0.009016853,0.016173085,-0.027479932,0.002934055,0.042937394,-0.004830457,-0.031201173,-0.024188064,0.00245101,0.017318081,0.001824839,-0.022756819,0.021325571,-0.027479932,-0.008659041,0.008337011,-0.016674021,-0.003452882,0.000711151,-0.045799885,0.013739966,-0.029340552,-0.035208661,0.000554608,-0.007800293,0.018892452,0.028481804,-0.011593096,-0.00894529,0.024474313,-0.008050761,0.025476186,-0.001306012,-0.00214687,-0.008050761,-0.018606203,-0.006047016,-0.028768053,0.029197427,-0.021468697,0.005402955,-0.021039322,-0.014312465,-0.002325775,-0.020896198,0.000706678,0.035638034,-0.008480135,-0.035351787,0.014312465,0.012523406,0.011807784,0.003041399,-0.010018725,-0.022613693,-0.021182448,-0.005474518,-0.007120451,0.025476186,0.036926158,-0.007907636,-0.014097777,0.010519661,0.005617642,0.014670276,-0.011664659,0.011879345,-0.012738093,-0.007871855,-0.012666531,0.032918669,-0.010018725,0.007943418,0.024188064,0.005760767,-0.003918037,0.022613693,0.017318081,0.036496785,0.037784904,0.008694822,0.016674021,0.000106225,0.003685459,-0.031201173,-0.01016185,-0.02404494,-0.019035578,0.031773672,0.000975037,-0.032489292,-0.033920541,0.015385899,-0.023186192,0.012523406,-0.011163722,-0.005116706,0.015314337,-0.006834202,-0.038357403,-0.023472441,0.015529023,0.017747456,0.005653423,-0.002325775,0.009088415,-0.022899942,0.02433119,0.000849803,-0.042078644,-0.004257958,0.018176829,-0.0049378,-0.002415228,-0.016173085,0.012594969,0.013596841,-0.017031832,-0.001806949,-0.003810694,0.003005618,0.046944883,-0.025476186,0.012738093,0.009016853,-0.009660914,0.012666531,0.014026215,-0.010519661,0.022327444,0.00400749,-0.007478263,-0.03578116,0.009804038,-0.028911177,-0.018248392,0.004758894,0.005939673,0.033920541,-0.011378409,-0.005474518,0.012451844,0.018176829,0.033920541,0.025905561,-0.014670276,0.001798003,0.031344298,0.00431163,0.027193682,-0.006798421,0.011449971,0.00894529,0.013883091,0.023758691,-0.007692949,0.031344298,-0.014384027,-0.007514044,-0.026621183,-0.001645933,-0.010090288,-0.009589351,0.008193886,-0.007871855,-0.031773672,0.013525278,0.006583733,0.010949035,-0.004794675,-0.004061162,-0.021468697,0.011020597,-0.020609949,0.010018725,0.010662786,0.008158104,0.00370335,0.007800293,-0.029626802,0.029197427,-0.017174957,-0.00586811,-0.003112961,-0.018749328,-0.042364895,0.027050557,0.028624929,0.008837947,0.026334934,0.018248392,-0.004758894,0.009446226,-0.033061791,-0.022041194,-0.021039322,0.008086543,-0.009088415,-0.031630546,0.020896198,-0.018749328,0.022613693,-0.014097777,0.004347411,0.014813401,-0.013525278,-0.001726441,0.010448099,0.036067411,-0.026048684,-0.020753073,-0.005045144,0.033348043,-0.002576244,0.02404494,0.022041194,0.017031832,-0.000297431,-0.003184523,-0.012738093,0.022756819,-0.016888708,0.021039322,-0.000313085,0.032203045,-0.011235285,0.001583316,-0.00461577,-0.026334934,-0.002934055,-0.005939673,0.001458082,0.007156232,-0.005689205,-0.042937394,0.011378409,0.007156232,0.00554608,0.026621183,-0.014455589,-0.017604331,-0.02647806,-0.03578116,-0.009804038,0.006905764,-0.0197512,-0.035494912,-0.027623056,-0.00461577,0.011521534,0.006905764,0.009517789,0.003112961,0.033920541,-0.004687332,-0.005045144,-0.009231539,0.000126911,0.008694822,-0.029340552,0.011163722,0.047517382,-0.039788652,-0.033348043,-0.003041399,-0.007657168,-0.035065539,-0.012165595,-0.024617439,0.0049378,0.017461207,0.029626802,-0.004723113,-0.000366757,-0.041792396,0.041219898,-0.009446226,0.016960271,-0.017747456,-0.036067411,0.025046812,0.027336806,0.025905561,0.049234878,0.016602458,-0.005796548,0.021325571,-0.003524444,-0.000872166,0.014670276,0.020323699,0.002737259,0.009660914,-0.006440609,-0.062402345,-0.062688597,-0.008158104,-0.018749328,0.005438737,-0.002066362,0.000205742,-0.018749328,0.017103394,-0.03578116,0.000265004,-0.03663991,-0.024760563,0.054101113,-0.00647639,-0.026334934,0.034779288,0.022756819,-0.033348043,-0.02433119,-0.041792396,-0.014455589,-0.023329318,-0.004687332,-0.013453716,-0.018319955,-0.014455589,0.043509893,0.013453716,-0.014813401,0.009052633,-0.034349915,0.052097369,-0.003774913,0.016316209,-0.027050557,0.028195554,-0.007549825,-0.020466823,0.014598713,-0.005939673,0.003273976,-0.052097369,0.002701478,-0.02404494,-0.005903892,0.009947163,-0.00043161,0.02189807,0.042078644,-0.020609949,0.007836075,0.018892452,0.001207614,0.009159978,-0.029197427,-0.023329318,0.004347411,-0.019464951,0.020180576,0.019894326,0.00615436,0.021468697,-0.017461207,-0.011879345,-0.002307885,0.016101522,-0.029626802,-0.014455589,0.020323699,0.020753073,0.018176829,-0.006082797,0.027766181,0.016530896,-0.008444354,0.001806949,0.029626802,-0.012451844,0.023186192,0.006869983,-0.034063663,-0.012094032,-0.021611821,-0.008050761,0.05581861,-0.004257958,-0.025333062,-0.004526317,0.018033706,0.027479932,0.025476186,0.008802165,-0.009589351,0.012809656,0.012523406,0.0400749,0.018033706,0.011020597,0.014956526,0.013883091,-0.006655296,0.019608077,-0.03234617,0.007585606,-0.036067411,-0.024617439,-0.001628043,0.022041194,0.026764309,-0.038643654,-0.009124196,-0.020323699,-0.013883091,0.02404494,0.002361557,-0.03234617,-0.0049378,0.018606203,0.022327444,0.043509893,-0.030485548,-0.003560225,0.007442481,0.00370335,0.011449971,0.023472441,0.000197915,-0.011950907,0.023329318,-0.009804038,-0.025619311,0.0074067,-0.003953818,0.014312465,0.048662379,-0.027193682,0.019894326,-0.042364895,0.003327648,0.042937394,-0.040933646,-0.020466823,0.056104861,0.020896198,-0.014527151,-0.036210533,-0.022470569,0.035924286,-0.013167467,-0.055532362,-0.006190141,-0.027909305,0.012881218,0.003005618,0.005689205,0.01109216,-0.016387772,-0.021468697,0.018176829,-0.021611821,0.032918669,0.002951946,-0.008837947,-0.031773672,-0.029913051,0.017318081,0.017461207,-0.02833868,-0.027479932,-0.023615567,0.037212405,-0.023615567,-0.02404494,0.029626802,0.002951946,0.004043271,-0.001377575,0.007800293,0.024188064,-0.027336806,-0.002361557,-0.00307718,-0.025189938,0.007192013,-0.000207978,0.040933646,0.010877473,-0.000720096,-0.006941545,0.003059289,0.032775544,-0.007657168,0.019321827,-0.012094032,0.042078644,-0.010591224,0.011807784,-0.016173085,-0.015529023,-0.023615567,0.016173085,-0.018606203,0.007192013,-0.008587479,0.000257177,0.002245268,-0.011879345,0.044082388,-0.005939673,-0.003059289,-0.013954652,-0.026621183,0.039502401,-0.006440609,0.014384027,0.012094032,-0.034779288,-0.002379447,0.023329318,0.029483676,-0.002325775,-0.001565426,0.025619311,0.018606203,-0.016101522,-0.0301993,0.002576244,0.035208661,0.002325775,-0.011664659,-0.022470569,-0.047231134,-0.016888708,-0.017747456,0.05152487,0.009374664,-0.010591224,0.009303101,-0.005009362,-0.029197427,0.001726441,-0.023758691,-0.002934055,-0.017461207,0.018606203,-0.002665696,-0.003578116,-0.018606203,-0.004651551,-0.021325571,0.005367174,-0.009124196,0.016888708,-0.01295278,0.002048471,-0.011593096,0.017604331,-0.008515916,0.006082797,-0.036067411,-0.027336806,-0.010018725,-0.001306012,0.026334934,-0.019321827,-0.030914923,-0.026764309,-0.0024689,-0.005581861,-0.002755149,0.019464951,-0.01295278,0.011163722,0.000639588,0.025476186,0.029483676,0.042651143,-0.011306847,0.002737259,0.010090288,-0.015600586,0.038357403,0.029197427,-0.008193886,0.044082388,0.032489292,-0.00123445,-0.008372792,0.009124196,-0.00309507,-0.041792396,0.007764512,-0.009947163,0.044941138,0.030056175,-0.013024342,-0.019321827,0.019321827,0.008551697,-0.053814866,0.038071156,-0.037784904,0.012165595,-0.008444354,-0.029626802,-0.006905764,-0.028195554,-0.01080591,-0.0098756,-0.032203045,0.040361151,-0.033920541,0.004454754,-0.036067411,0.011879345,-0.011235285,0.020609949,-0.004579989,0.0074067,-0.017103394,0.01789058,0.011449971,-0.007836075,0.000427138,-0.007120451,0.008337011,0.00123445,-0.003273976,-0.007263576,-0.011449971,0.022756819,0.002576244,-0.013310592,-0.013382155,-0.011664659,-0.013453716,-0.005152487,-0.050379876,-0.034636162,-0.011306847,0.015028087,0.008480135,-0.047517382,-0.00586811,-0.008301229,-0.01416934,0.000876638,0.000326503,0.01080591,0.004150615,0.005259831,-0.008837947,0.017031832,-0.016316209,-0.036210533,-0.013883091,-0.000295195,0.014240902,0.020753073,-0.022899942,-0.038929902,0.00586811,-0.008050761,0.00016437,-0.001932183,0.001789058,0.017031832,0.045227386,-0.016745584,-0.005689205,0.008372792,0.008301229,-0.016674021,-0.004222177,0.005832329,0.016173085,-0.009374664,-0.006869983,-0.052669868,0.035065539,0.000123557,0.007478263,0.033491168,0.054387365,0.002254213,-0.007836075,-0.020323699,-0.019178702,-0.010376536,-0.039788652,-0.032632418,-0.012380281,-0.002540462,-0.016602458,-0.022756819,0.019608077,0.001887456,0.032918669,0.008050761,-0.013739966,0.006547953,-0.016674021,0.001574371,0.019321827,-0.016960271,-0.031201173,0.027766181,0.006655296,0.020753073,0.009804038,0.024903689,-0.043509893,0.015815273,-0.017962143,-0.043223642,0.033920541,-0.007764512,-0.006762639,0.017819017,-0.026621183,0.046658635,-0.004490536,0.024188064,-0.010304974,0.004651551,0.047231134,-0.038071156,0.009589351,-0.033920541,-0.027050557,0.050093625,0.008515916,-0.025189938,-0.008050761,0.011950907,0.004973582,0.014527151,-0.009374664,-0.003721241,0.019608077,0.049807377,0.016602458,0.02404494];
  3. 파일을 저장하고 닫습니다.

2

터미널 창에서 mongosh 을 열고 클러스터에 연결합니다. 연결에 대한 자세한 지침은 mongosh 를 통해 클러스터에 연결을 참조하세요.

3

mongosh 프롬프트에서 다음 명령을 실행합니다.

use sample_mflix
switched to db sample_mflix
4

<path-to-file>embeddings.js 파일의 절대 경로로 바꾼 후 다음 명령을 실행하여 임베딩을 로드합니다.

load('/<path-to-file>/embeddings.js');

임베딩이 성공적으로 로드되었는지 확인하려면 다음 명령을 실행 .

STAR_WARS_EMBEDDING.length
2048
5
1db.embedded_movies.aggregate([
2 {
3 $rankFusion: {
4 input: {
5 pipelines: {
6 vectorPipeline: [
7 {
8 "$vectorSearch": {
9 "index": "hybrid-vector-search",
10 "path": "plot_embedding_voyage_3_large",
11 "queryVector": STAR_WARS_EMBEDDING,
12 "numCandidates": 100,
13 "limit": 20
14 }
15 }
16 ],
17 fullTextPipeline: [
18 {
19 "$search": {
20 "index": "hybrid-full-text-search",
21 "phrase": {
22 "query": "star wars",
23 "path": "title"
24 }
25 }
26 },
27 { "$limit": 20 }
28 ]
29 }
30 },
31 combination: {
32 weights: {
33 vectorPipeline: 0.5,
34 fullTextPipeline: 0.5
35 }
36 },
37 "scoreDetails": true
38 }
39 },
40 {
41 "$project": {
42 _id: 1,
43 title: 1,
44 plot: 1,
45 scoreDetails: {"$meta": "scoreDetails"}
46 }
47 },
48 {
49 "$limit": 10
50 }
51]);
[
{
_id: ObjectId('573a1397f29313caabce68f6'),
plot: "Luke Skywalker joins forces with a Jedi Knight, a cocky pilot, a wookiee and two droids to save the universe from the Empire's world-destroying battle-station, while also attempting to rescue Princess Leia from the evil Darth Vader.",
title: 'Star Wars: Episode IV - A New Hope',
scoreDetails: {
value: 0.01626123744050767,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{
inputPipelineName: 'fullTextPipeline',
rank: 2,
weight: 0.5,
value: 2.9571781158447266,
details: []
},
{
inputPipelineName: 'vectorPipeline',
rank: 1,
weight: 0.5,
value: 0.7987099885940552,
details: []
}
]
}
},
{
_id: ObjectId('573a139af29313caabcf0f5f'),
plot: 'Two Jedi Knights escape a hostile blockade to find allies and come across a young boy who may bring balance to the Force, but the long dormant Sith resurface to reclaim their old glory.',
title: 'Star Wars: Episode I - The Phantom Menace',
scoreDetails: {
value: 0.015527202696196438,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{
inputPipelineName: 'fullTextPipeline',
rank: 2,
weight: 0.5,
value: 2.9571781158447266,
details: []
},
{
inputPipelineName: 'vectorPipeline',
rank: 7,
weight: 0.5,
value: 0.7771433591842651,
details: []
}
]
}
},
{
_id: ObjectId('573a1397f29313caabce77d9'),
plot: 'After the rebels have been brutally overpowered by the Empire on their newly established base, Luke Skywalker takes advanced Jedi training with Master Yoda, while his friends are pursued by Darth Vader as part of his plan to capture Luke.',
title: 'Star Wars: Episode V - The Empire Strikes Back',
scoreDetails: {
value: 0.015504807692307693,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{
inputPipelineName: 'fullTextPipeline',
rank: 4,
weight: 0.5,
value: 2.712062358856201,
details: []
},
{
inputPipelineName: 'vectorPipeline',
rank: 5,
weight: 0.5,
value: 0.7810181975364685,
details: []
}
]
}
},
{
_id: ObjectId('573a1397f29313caabce8cdb'),
plot: 'After rescuing Han Solo from the palace of Jabba the Hutt, the rebels attempt to destroy the second Death Star, while Luke struggles to make Vader return from the dark side of the Force.',
title: 'Star Wars: Episode VI - Return of the Jedi',
scoreDetails: {
value: 0.015388257575757576,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{
inputPipelineName: 'fullTextPipeline',
rank: 4,
weight: 0.5,
value: 2.712062358856201,
details: []
},
{
inputPipelineName: 'vectorPipeline',
rank: 6,
weight: 0.5,
value: 0.7782549858093262,
details: []
}
]
}
},
{
_id: ObjectId('573a13c0f29313caabd62f62'),
plot: 'Anakin Skywalker and Ahsoka Tano must rescue the kidnapped son of Jabba the Hutt, but political intrigue complicates their mission.',
title: 'Star Wars: The Clone Wars',
scoreDetails: {
value: 0.015141165755919854,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{
inputPipelineName: 'fullTextPipeline',
rank: 1,
weight: 0.5,
value: 3.609658718109131,
details: []
},
{
inputPipelineName: 'vectorPipeline',
rank: 12,
weight: 0.5,
value: 0.7561323642730713,
details: []
}
]
}
},
{
_id: ObjectId('573a139af29313caabcf124d'),
plot: 'As the Clone Wars near an end, the Sith Lord Darth Sidious steps out of the shadows, at which time Anakin succumbs to his emotions, becoming Darth Vader and putting his relationships with Obi-Wan and Padme at risk.',
title: 'Star Wars: Episode III - Revenge of the Sith',
scoreDetails: {
value: 0.014854753521126762,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{
inputPipelineName: 'fullTextPipeline',
rank: 4,
weight: 0.5,
value: 2.712062358856201,
details: []
},
{
inputPipelineName: 'vectorPipeline',
rank: 11,
weight: 0.5,
value: 0.756283700466156,
details: []
}
]
}
},
{
_id: ObjectId('573a139af29313caabcf1258'),
plot: 'Ten years after initially meeting, Anakin Skywalker shares a forbidden romance with Padmè, while Obi-Wan investigates an assassination attempt on the Senator and discovers a secret clone army crafted for the Jedi.',
title: 'Star Wars: Episode II - Attack of the Clones',
scoreDetails: {
value: 0.014391447368421052,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{
inputPipelineName: 'fullTextPipeline',
rank: 4,
weight: 0.5,
value: 2.712062358856201,
details: []
},
{
inputPipelineName: 'vectorPipeline',
rank: 16,
weight: 0.5,
value: 0.7400004267692566,
details: []
}
]
}
},
{
_id: ObjectId('573a1398f29313caabce9091'),
plot: "A Duke's son leads desert warriors against the galactic emperor and his father's evil nemesis when they assassinate his father and free their desert world from the emperor's rule.",
title: 'Dune',
scoreDetails: {
value: 0.008064516129032258,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{ inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 },
{
inputPipelineName: 'vectorPipeline',
rank: 2,
weight: 0.5,
value: 0.7947750091552734,
details: []
}
]
}
},
{
_id: ObjectId('573a1397f29313caabce6f53'),
plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...',
title: 'Message from Space',
scoreDetails: {
value: 0.007936507936507936,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{ inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 },
{
inputPipelineName: 'vectorPipeline',
rank: 3,
weight: 0.5,
value: 0.7913960218429565,
details: []
}
]
}
},
{
_id: ObjectId('573a139df29313caabcfa90b'),
plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...',
title: 'Message from Space',
scoreDetails: {
value: 0.007936507936507936,
description: 'value output by reciprocal rank fusion algorithm, computed as sum of (weight * (1 / (60 + rank))) across input pipelines from which this document is output, from:',
details: [
{ inputPipelineName: 'fullTextPipeline', rank: 0, weight: 0.5 },
{
inputPipelineName: 'vectorPipeline',
rank: 3,
weight: 0.5,
value: 0.7913960218429565,
details: []
}
]
}
}
]

샘플 쿼리는 시맨틱 검색과 전체 텍스트 검색에서 정렬된 검색 결과를 조회하고, 결과 배열에서의 문서 위치에 따라 결과에 있는 문서에 상호 순위 점수를 할당합니다. 상호 순위 점수는 다음 공식을 사용하여 계산합니다.

1.0/{document position in the results + constant value}

쿼리는 각 문서에 대해 두 검색의 점수를 합산하고 합산된 점수에 따라 문서를 순위 매긴 후 단일 결과를 반환하기 위해 문서를 정렬합니다. 상수의 값은 항상 60입니다.

샘플 쿼리는 각 파이프라인의 최종 점수에 대한 순위 기여도를 조정하기 위해 다음과 같은 가중치를 정의합니다.

  • vectorPipeline = 0.5

  • fullTextPipeline = 0.5

가중치를 조정하여 특정 검색 방법에 더 많은 중요성을 부여할 수 있습니다. 숫자가 낮을수록 더 높은 가중치를 제공합니다.

가중 상호 순위 점수는 다음 공식을 사용하여 계산합니다.

weight x reciprocal rank

scoreDetails.value는 가중치가 부여되고 상호 순위 융합을 통해 결합되기 전에 해당 파이프라인의 원시 점수를 보여줍니다. scoreDetails.details.value는 가중 상호 순위 점수를 보여줍니다.

샘플 쿼리는 $rankFusion 단계를 사용하여 시맨틱 쿼리와 전체 텍스트 쿼리를 독립적으로 실행한 후 중복을 제거하고 입력 쿼리 결과를 최종 순위 결과 집합으로 결합합니다. 입력 파이프라인에 나타나는 순위와 파이프라인 가중치를 기준으로 순위가 매겨진 문서 집합을 반환합니다. 구체적으로, 이 단계는 다음과 같은 입력 파이프라인을 입력으로 사용합니다.

vectorPipeline

이 파이프라인에는 $vectorSearch 쿼리가 포함되어 있습니다. 쿼리의 queryVector 필드에 벡터 임베딩으로 지정된 문자열 star warsplot_embedding_voyage_3_large 필드에서 검색합니다. 이 쿼리는 Voyage AI의 voyage-3-large 임베딩 모델을 사용하며, 이는 plot_embedding_voyage_3_large 필드의 임베딩에 사용된 모델과 동일합니다. 쿼리는 최대 100개의 최근접 이웃에 대한 검색을 지정하고 결과를 문서 20개로만 제한합니다. 이 단계에서는 시맨틱 검색에서 정렬된 문서를 결과로 반환합니다.

fullTextPipeline

이 파이프라인에는 다음 단계가 포함됩니다.

  • $search를 사용하여 title 필드에 star wars 텀이 포함된 영화를 검색합니다. 이 단계에서는 전체 텍스트 검색에서 정렬된 문서를 결과로 반환합니다.

  • $limit를 사용하여 $search 단계의 출력을 20개 결과로만 제한합니다.

샘플 쿼리는 다음 단계를 사용하여 시맨틱 및 텍스트 검색 결과를 결합하고 결과에서 단일 순위의 문서 목록을 반환합니다.

결과에 다음 필드만 포함합니다.

  • _id

  • title

  • plot

  • scoreDetails

출력을 10 결과로만 제한합니다.

이 섹션에서는 sample_mflix.embedded_movies 단계 plot_embedding_voyage_3_large title 내의 $vectorSearch$search 파이프라인 단계를 사용하여 $scoreFusion 다시 정렬하여 및 필드에서 스타 워즈에 대한 컬렉션 의 데이터를 쿼리 $scoreFusion 방법을 보여 줍니다. 합산 점수에 따라 결과에 문서가 표시됩니다. 단계에서는 수학적 표현식을 사용하여 문서 의 점수를 결합하고 결과에서 문서 의 위치에 영향을 줍니다.

1
  1. query-embeddings.js이라는 파일을 만듭니다.

  2. 다음 임베딩을 복사하여 파일 에 붙여넣습니다.

    STAR_WARS_EMBEDDING=[-0.025189938,0.014741838,-0.013024342,-0.0197512,0.011235285,0.004651551,0.043509893,0.003112961,0.013310592,-0.033348043,0.037212405,-0.021039322,-0.026048684,0.012809656,0.029483676,0.003578116,-0.044654887,0.032632418,0.014312465,-0.058967352,0.025333062,-0.055246111,0.02189807,-0.017604331,-0.002880384,0.045227386,0.004794675,0.017604331,0.023186192,-0.054673612,-0.011306847,-0.012523406,-0.012380281,0.002540462,0.015958399,-0.042364895,-0.001467028,-0.020180576,-0.058108605,-0.035065539,0.010090288,-0.033348043,0.058394853,-0.013883091,0.002048471,-0.020753073,-0.029769925,0.031916797,-0.014741838,-0.040933646,-0.004096943,0.020753073,-0.002540462,0.028052431,-0.02404494,0.006547953,-0.003578116,0.003757022,0.019178702,-0.037784904,-0.02833868,0.01753277,0.029769925,0.017747456,-0.031344298,0.022899942,0.006333265,0.010376536,-0.024474313,-0.012094032,-0.004651551,0.007764512,0.017962143,0.013811528,0.037212405,-0.03148742,0.000666424,0.024474313,-0.021325571,0.041219898,0.011235285,0.046658635,0.019035578,0.020753073,0.010662786,-0.001726441,-0.012738093,-0.027193682,-0.014598713,-0.013167467,0.013596841,0.001932183,-0.010304974,-0.007478263,0.005689205,0.002987727,0.005724986,0.002325775,0.002415228,-0.003828584,-0.029340552,-0.017318081,-0.070417322,0.003810694,-0.013453716,-0.001628043,-0.027909305,0.014026215,0.009589351,0.004902019,0.028768053,-0.005259831,-0.010448099,0.025189938,0.038357403,0.048662379,0.039788652,0.010448099,0.001574371,0.020323699,0.005510299,0.026907433,0.043223642,-0.001153942,-0.010233412,0.048376128,-0.056104861,0.006691077,0.015672149,-0.015028087,0.036210533,-0.009231539,0.010519661,0.022899942,0.025762435,-0.009052633,-0.0301993,0.032203045,-0.00522405,0.029626802,-0.02433119,-0.025619311,0.016674021,0.02404494,-0.009589351,-0.026334934,-0.04436864,-0.014455589,0.02619181,0.017604331,0.02189807,-0.007728731,-0.021611821,-0.03363429,0.008480135,-0.027479932,0.025046812,-0.006047016,0.020753073,0.01016185,-0.034063663,0.029483676,-0.019035578,0.041506145,0.013453716,-0.009159978,0.007549825,0.025189938,0.005152487,-0.009446226,-0.009016853,0.021325571,0.030771798,-0.046944883,0.001314958,0.021182448,0.047231134,-0.007048889,-0.030771798,-0.025905561,-0.000612752,-0.023186192,0.011378409,0.035065539,0.007979199,0.023901815,-0.004973582,0.005188268,-0.046944883,0.009374664,0.047231134,0.058967352,0.043509893,0.011449971,0.017174957,-0.024188064,-0.025476186,-0.02833868,0.033061791,0.015314337,-0.018749328,0.013382155,0.007048889,0.005975454,0.005295612,-0.013310592,-0.022756819,-0.012523406,-0.03363429,-0.014527151,0.011449971,0.01202247,0.044941138,-0.012594969,0.002862493,0.000572499,0.030628674,-0.0098756,0.020466823,0.059539851,-0.00370335,0.007335138,0.023901815,0.023758691,-0.005903892,0.003918037,0.013310592,0.010090288,-0.012809656,-0.010376536,-0.01109216,-0.008086543,0.012809656,-0.019894326,0.012738093,0.056391109,0.029340552,-0.04436864,-0.001619098,0.042364895,-0.027623056,0.011593096,-0.031916797,-0.0301993,0.032203045,-0.003757022,0.017174957,0.033491168,0.003900147,0.002325775,0.006726858,0.020180576,0.017389644,0.009088415,0.018319955,-0.003631788,0.00586811,-0.006691077,-0.014240902,-0.009052633,0.031630546,0.04436864,-0.022899942,-0.003327648,-0.006691077,0.013310592,-0.035924286,-0.008158104,-0.005116706,-0.040647399,0.002397338,0.014455589,-0.030342424,0.028624929,-0.031773672,0.043509893,-0.001833785,-0.025619311,0.032775544,-0.046944883,0.013739966,-0.030485548,0.018319955,0.016745584,-0.020323699,-0.015815273,-0.020896198,-0.015171212,0.026334934,0.035638034,0.008873728,0.003291867,-0.02647806,0.003649678,0.003613897,0.009804038,-0.013525278,0.005367174,0.007657168,-0.017103394,-0.015815273,-0.000398065,0.013310592,0.014240902,0.003935928,0.001735386,-0.018606203,0.008265448,-0.068127327,0.012165595,-0.007836075,0.02189807,-0.000983982,0.019178702,-0.009589351,-0.013739966,-0.007800293,0.040361151,0.027623056,-0.002540462,-0.03663991,0.011163722,-0.016316209,-0.006333265,-0.010877473,-0.023329318,-0.021468697,0.013596841,0.032059919,0.007442481,0.02433119,-0.003613897,-0.013596841,0.010448099,0.010877473,-0.0098756,0.033920541,-0.006691077,-0.039502401,-0.010877473,-0.016960271,0.014097777,-0.008122323,0.007478263,0.010018725,-0.030485548,-0.011020597,0.000317558,0.00461577,0.020466823,0.070703574,-0.024617439,0.002111088,-0.024617439,-0.004204286,-0.048662379,-0.006834202,0.027766181,-0.002504681,0.025189938,0.033920541,-0.02833868,-0.000773768,-0.03578116,0.015958399,0.006369046,0.033204917,-0.006762639,0.02003745,-0.020180576,0.015886836,-0.015385899,-0.029340552,-0.009446226,0.015529023,-0.010376536,-0.012881218,-0.000715623,0.014312465,-0.029197427,-0.000684315,0.000360048,0.015815273,-0.027050557,0.006655296,0.018892452,-0.021182448,0.031201173,0.014240902,-0.022756819,0.004365302,-0.020609949,0.008515916,-0.016244646,0.001162888,0.000084421,0.003273976,-0.017819017,0.000576971,0.020753073,-0.004794675,0.018105267,-0.013095905,-0.028052431,0.004114834,0.02833868,-0.027193682,-0.010877473,-0.002576244,0.011879345,-0.017819017,0.006726858,-0.021754947,-0.031773672,-0.013382155,0.024903689,0.013167467,0.000033964,0.034063663,0.022613693,-0.038357403,-0.010018725,-0.017174957,-0.004418973,0.02189807,-0.003166633,-0.009589351,0.009303101,-0.036496785,-0.005760767,-0.006583733,-0.003596007,0.014026215,-0.003828584,-0.02833868,-0.020896198,0.001449137,0.039502401,0.012881218,0.025476186,0.000961619,-0.025762435,0.002808821,0.034922414,0.004687332,-0.046658635,0.030914923,-0.036067411,0.008659041,-0.004025381,-0.0301993,-0.026048684,0.024760563,0.036496785,-0.029913051,0.015672149,0.007764512,0.01509965,0.010304974,-0.004490536,-0.007585606,-0.019464951,0.016602458,-0.007048889,-0.005510299,0.011163722,0.013739966,-0.034636162,0.020609949,-0.004418973,0.034636162,0.040933646,0.031773672,0.023758691,0.031344298,-0.006798421,0.026048684,-0.011521534,0.020753073,0.014384027,0.026334934,-0.034206789,-0.036067411,0.014598713,0.023758691,-0.039216153,0.003363429,0.002880384,-0.006726858,-0.000916892,-0.001395465,-0.009660914,0.032059919,0.008086543,0.029054303,-0.011593096,0.065551087,0.031058047,-0.041219898,-0.014097777,-0.017103394,0.016244646,-0.028911177,0.044654887,-0.030771798,0.024760563,0.02833868,0.018248392,0.026907433,-0.002227377,0.034063663,0.000167724,0.021039322,-0.018892452,0.012738093,-0.001395465,0.005760767,-0.024760563,-0.002683587,0.000230341,-0.0197512,0.009088415,-0.00400749,-0.026764309,-0.012881218,0.016101522,-0.009303101,0.015529023,-0.016817145,0.014312465,-0.030914923,-0.018463079,0.020323699,-0.023472441,-0.023758691,-0.005009362,0.018176829,0.012738093,0.009374664,-0.031916797,0.016387772,0.027479932,0.015529023,-0.021325571,0.020323699,-0.025476186,0.008515916,-0.039788652,-0.007979199,-0.009947163,-0.006869983,0.004758894,0.022613693,-0.013668403,-0.015171212,0.035351787,-0.022327444,0.019178702,0.000404774,-0.003524444,-0.012094032,0.023901815,-0.0400749,-0.004579989,0.00245101,0.013024342,0.015958399,0.009517789,0.034779288,0.021468697,0.00062617,0.007728731,-0.028195554,0.0301993,-0.002504681,0.008909509,0.004651551,-0.007013108,0.03148742,0.019608077,0.002540462,0.043509893,-0.006190141,0.024903689,0.010519661,0.018319955,0.010519661,0.009660914,0.000966091,-0.004454754,0.000299667,0.007907636,-0.018463079,0.004758894,-0.001851675,-0.002415228,0.010233412,-0.024617439,-0.030771798,0.018749328,0.003023508,0.005474518,-0.011521534,-0.008551697,0.007979199,0.03363429,0.000275068,0.007800293,0.0039896,0.00522405,-0.035924286,-0.01416934,0.02619181,-0.025476186,-0.033777416,0.021325571,-0.02218432,0.001833785,0.027766181,-0.006118578,0.032059919,0.038929902,0.003613897,0.031344298,-0.002737259,0.057536107,0.009732476,0.020753073,0.005402955,-0.047803629,-0.040933646,0.009052633,-0.030485548,0.018319955,0.025046812,-0.002361557,0.045513637,0.008766385,-0.031058047,0.014312465,0.002737259,-0.004186396,0.032059919,0.024617439,-0.012666531,0.006798421,0.02619181,-0.012523406,0.009947163,0.005617642,0.039216153,0.008766385,0.009517789,0.042651143,-0.012881218,0.007263576,-0.000514354,0.016817145,-0.048948627,0.018176829,0.034922414,0.005331393,0.000391356,-0.017604331,0.026048684,-0.011807784,0.017461207,0.012809656,0.029483676,-0.017174957,0.023472441,0.005188268,0.007585606,-0.034922414,0.069558576,0.023472441,-0.010304974,0.020180576,0.025046812,0.016459335,0.000317558,-0.018606203,0.066696085,0.011664659,0.025762435,-0.016888708,0.015314337,-0.009231539,0.016459335,-0.021325571,0.009303101,0.000840857,-0.014455589,0.00170855,0.014741838,-0.004168505,-0.009088415,-0.0074067,-0.004472645,0.002665696,0.023615567,0.038929902,-0.016960271,-0.027193682,0.03663991,-0.016530896,0.003256086,0.015171212,0.036926158,0.02433119,0.047231134,-0.049234878,0.009947163,-0.01109216,-0.014097777,-0.007585606,0.00338132,-0.008086543,0.018176829,-0.014527151,-0.000205742,-0.041219898,0.012666531,0.046086136,0.004025381,-0.0074067,0.033348043,-0.020896198,-0.000514354,0.033491168,0.004257958,0.02404494,-0.008372792,-0.021754947,0.037784904,0.013453716,0.013024342,-0.026334934,0.023758691,0.012094032,0.006297485,0.045227386,0.021039322,-0.020323699,0.005975454,0.008802165,0.00370335,0.006941545,-0.029340552,-0.008551697,-0.004454754,0.003488663,0.010662786,0.00801498,0.010090288,0.015600586,0.018105267,-0.020180576,-0.00307718,0.031630546,0.000644061,0.011950907,-0.023472441,0.01509965,-0.035924286,0.016459335,-0.027766181,-0.014598713,-0.021611821,-0.013310592,-0.021039322,-0.02189807,0.018606203,-0.007979199,0.018176829,0.022041194,-0.002916165,0.009088415,-0.00522405,-0.018176829,-0.031916797,-0.017318081,-0.025476186,-0.014527151,-0.017675893,-0.026621183,0.000362284,0.02619181,0.016101522,-0.013310592,0.021325571,0.027909305,0.016316209,0.006011235,0.008551697,0.030914923,-0.070703574,0.004794675,-0.019321827,-0.011163722,-0.014598713,-0.0197512,-0.005438737,-0.025189938,-0.037212405,0.004168505,-0.021754947,0.018033706,0.035065539,0.022756819,0.005581861,-0.007764512,-0.003005618,-0.003524444,0.006655296,-0.00170855,-0.046086136,-0.009374664,0.001744332,0.030056175,0.016674021,0.014312465,0.029054303,-0.009052633,0.005832329,-0.029197427,-0.004723113,0.032489292,0.022899942,-0.044941138,0.014026215,-0.007227794,-0.035494912,0.001261286,0.079004802,0.008122323,0.022041194,0.016602458,0.046658635,-0.016888708,-0.006547953,-0.016316209,0.002021636,-0.016745584,0.003792803,0.005116706,-0.037784904,-0.028481804,-0.014670276,-0.005259831,0.018892452,0.001252341,-0.068699829,-0.021611821,-0.015242774,-0.027050557,-0.032059919,0.026048684,-0.014240902,-0.007013108,0.014598713,-0.005474518,-0.007192013,-0.016817145,0.00400749,0.010519661,0.007657168,0.005295612,0.009124196,0.024474313,-0.019894326,-0.044941138,-0.022756819,-0.022327444,-0.041792396,0.027479932,-0.013668403,-0.036210533,0.001225505,0.009947163,-0.044654887,-0.02003745,0.031344298,-0.004186396,-0.009517789,0.000720096,-0.023901815,0.000670897,0.022899942,0.006619515,0.006512171,0.022327444,0.021468697,0.021611821,0.039216153,-0.019608077,0.028052431,-0.020466823,-0.0197512,0.004454754,0.026048684,-0.024617439,-0.000333212,0.002200541,-0.002629915,0.021611821,0.009374664,0.00894529,-0.057822354,-0.009660914,-0.002844602,0.020323699,0.000603807,0.018033706,-0.027050557,-0.004186396,-0.019608077,-0.021754947,0.009732476,0.01602996,-0.016960271,-0.001520699,-0.023615567,0.004383192,0.000925838,0.023043068,0.032775544,0.006404828,-0.010304974,0.019321827,0.017604331,-0.01230872,0.007657168,0.005402955,-0.03148742,-0.000550135,-0.002111088,-0.029626802,0.01323903,-0.033777416,0.006655296,0.035065539,-0.003256086,0.000907947,0.004025381,0.011020597,-0.04808988,0.02619181,0.015171212,0.023758691,0.014741838,-0.001359684,-0.041506145,-0.009088415,-0.012738093,0.000176669,0.033777416,0.024188064,-0.002307885,0.023901815,0.00034663,-0.024474313,-0.031773672,-0.023758691,-0.024474313,-0.011163722,0.000447265,0.005080925,-0.00123445,0.006297485,-0.031058047,-0.012738093,-0.003059289,-0.026907433,-0.015672149,-0.005760767,0.023043068,0.023043068,-0.015028087,0.017747456,0.013883091,-0.011807784,0.038357403,-0.016817145,0.014884963,0.017389644,-0.000599334,0.016602458,0.008086543,-0.039502401,0.050379876,-0.024474313,0.035351787,-0.023758691,0.002039526,0.004061162,-0.012165595,-0.020180576,0.001636988,-0.013883091,0.017389644,0.006225922,-0.03578116,-0.016817145,-0.001332848,-0.005617642,-0.008730603,-0.039216153,0.02433119,0.028052431,0.02833868,0.039502401,0.010233412,-0.006869983,0.021468697,0.002039526,-0.0197512,0.020753073,0.027050557,0.009517789,0.011449971,0.038929902,0.008873728,0.009374664,0.007871855,-0.006082797,-0.007156232,-0.014670276,-0.000447265,0.046944883,-0.015242774,-0.019894326,0.008158104,0.016173085,-0.018463079,0.034922414,-0.005009362,-0.000092248,0.005760767,0.006190141,-0.022613693,0.034206789,0.012523406,0.000992927,0.038071156,-0.048376128,-0.017747456,0.014384027,0.000751404,0.015314337,-0.010519661,0.058681104,0.013954652,0.022899942,-0.003757022,0.01416934,-0.000469628,-0.008337011,-0.001153942,0.02189807,-0.024760563,0.01416934,-0.012738093,-0.025046812,0.030771798,-0.046658635,-0.002137924,0.053242367,0.010090288,-0.046086136,0.016316209,-0.005295612,0.023043068,-0.023043068,0.010233412,-0.018319955,-0.017389644,0.030485548,0.009660914,0.017174957,0.050379876,-0.010304974,0.017819017,-0.000364521,0.011163722,0.001753277,0.010448099,0.013095905,0.008372792,-0.01109216,0.036926158,-0.015672149,-0.014598713,0.008981071,-0.011879345,-0.036926158,-0.01789058,-0.008694822,-0.028911177,-0.017103394,-0.028768053,-0.030914923,0.001033181,0.00431163,-0.024474313,-0.031058047,0.010018725,0.00647639,-0.027336806,0.025046812,0.003148742,-0.010018725,0.03663991,0.033348043,-0.001162888,-0.01016185,0.010376536,0.010519661,0.019178702,0.016101522,0.007943418,-0.013739966,-0.013525278,-0.027193682,0.006655296,0.027050557,-0.017389644,-0.027479932,0.041792396,0.045513637,-0.014741838,0.012451844,0.018319955,-0.00153859,0.010519661,0.017962143,-0.012594969,0.018606203,0.023472441,-0.034063663,-0.004061162,0.015600586,0.019178702,0.002361557,-0.025619311,-0.00586811,-0.02003745,0.013739966,0.017675893,-0.025189938,-0.002415228,0.001547535,0.019608077,0.039502401,-0.00184273,0.025189938,0.00277304,0.020323699,0.007227794,0.012165595,-0.00370335,0.02433119,-0.00586811,0.016459335,0.034206789,0.001051072,-0.010519661,-0.004096943,0.00153859,0.01574371,0.01230872,-0.007692949,-0.019464951,0.005116706,0.017389644,0.024903689,0.046658635,-0.010519661,0.020609949,0.060684849,-0.045227386,-0.008551697,-0.004293739,-0.001502809,-0.015815273,-0.005975454,0.000290722,0.027050557,-0.002245268,-0.016888708,-0.027193682,-0.001288122,-0.021182448,-0.041219898,0.031916797,0.030628674,-0.03234617,0.006655296,0.008372792,-0.009016853,-0.033348043,0.010877473,-0.05238362,-0.004490536,-0.028911177,0.006905764,-0.003506554,0.039788652,-0.036496785,-0.015886836,0.015314337,-0.015672149,0.006225922,-0.021182448,-0.034349915,-0.043223642,-0.025476186,0.002558353,0.007048889,-0.037784904,-0.014026215,-0.044654887,-0.036926158,0.008229667,0.007728731,0.039216153,-0.00027954,0.026907433,0.027193682,-0.017174957,-0.011378409,0.017174957,-0.015815273,0.009446226,0.033777416,-0.014384027,0.003721241,-0.024760563,-0.000229223,0.008802165,-0.000377939,-0.007692949,0.016173085,0.018248392,-0.02218432,-0.003202414,-0.033204917,-0.002969836,-0.023186192,0.030056175,-0.015457462,-0.015314337,-0.008981071,0.022613693,-0.014026215,-0.025476186,0.025333062,0.034206789,0.010662786,0.016387772,0.030342424,-0.008086543,0.007120451,0.000221396,0.025619311,0.01789058,-0.008086543,0.011807784,-0.016101522,0.002719368,0.005653423,0.017962143,-0.001941128,0.06297484,0.016244646,0.003524444,0.018749328,-0.001815894,0.006082797,0.069558576,-0.011020597,0.018033706,0.026621183,0.007692949,-0.008694822,0.035924286,-0.001878511,-0.005975454,-0.028911177,-0.007871855,0.014741838,0.008587479,0.026621183,0.005259831,-0.023186192,0.000368993,-0.01323903,0.002683587,-0.011306847,0.007478263,-0.000621698,0.022756819,-0.018892452,-0.013167467,0.007764512,-0.010877473,-0.017461207,-0.013525278,0.014240902,-0.019464951,-0.009016853,0.016173085,-0.027479932,0.002934055,0.042937394,-0.004830457,-0.031201173,-0.024188064,0.00245101,0.017318081,0.001824839,-0.022756819,0.021325571,-0.027479932,-0.008659041,0.008337011,-0.016674021,-0.003452882,0.000711151,-0.045799885,0.013739966,-0.029340552,-0.035208661,0.000554608,-0.007800293,0.018892452,0.028481804,-0.011593096,-0.00894529,0.024474313,-0.008050761,0.025476186,-0.001306012,-0.00214687,-0.008050761,-0.018606203,-0.006047016,-0.028768053,0.029197427,-0.021468697,0.005402955,-0.021039322,-0.014312465,-0.002325775,-0.020896198,0.000706678,0.035638034,-0.008480135,-0.035351787,0.014312465,0.012523406,0.011807784,0.003041399,-0.010018725,-0.022613693,-0.021182448,-0.005474518,-0.007120451,0.025476186,0.036926158,-0.007907636,-0.014097777,0.010519661,0.005617642,0.014670276,-0.011664659,0.011879345,-0.012738093,-0.007871855,-0.012666531,0.032918669,-0.010018725,0.007943418,0.024188064,0.005760767,-0.003918037,0.022613693,0.017318081,0.036496785,0.037784904,0.008694822,0.016674021,0.000106225,0.003685459,-0.031201173,-0.01016185,-0.02404494,-0.019035578,0.031773672,0.000975037,-0.032489292,-0.033920541,0.015385899,-0.023186192,0.012523406,-0.011163722,-0.005116706,0.015314337,-0.006834202,-0.038357403,-0.023472441,0.015529023,0.017747456,0.005653423,-0.002325775,0.009088415,-0.022899942,0.02433119,0.000849803,-0.042078644,-0.004257958,0.018176829,-0.0049378,-0.002415228,-0.016173085,0.012594969,0.013596841,-0.017031832,-0.001806949,-0.003810694,0.003005618,0.046944883,-0.025476186,0.012738093,0.009016853,-0.009660914,0.012666531,0.014026215,-0.010519661,0.022327444,0.00400749,-0.007478263,-0.03578116,0.009804038,-0.028911177,-0.018248392,0.004758894,0.005939673,0.033920541,-0.011378409,-0.005474518,0.012451844,0.018176829,0.033920541,0.025905561,-0.014670276,0.001798003,0.031344298,0.00431163,0.027193682,-0.006798421,0.011449971,0.00894529,0.013883091,0.023758691,-0.007692949,0.031344298,-0.014384027,-0.007514044,-0.026621183,-0.001645933,-0.010090288,-0.009589351,0.008193886,-0.007871855,-0.031773672,0.013525278,0.006583733,0.010949035,-0.004794675,-0.004061162,-0.021468697,0.011020597,-0.020609949,0.010018725,0.010662786,0.008158104,0.00370335,0.007800293,-0.029626802,0.029197427,-0.017174957,-0.00586811,-0.003112961,-0.018749328,-0.042364895,0.027050557,0.028624929,0.008837947,0.026334934,0.018248392,-0.004758894,0.009446226,-0.033061791,-0.022041194,-0.021039322,0.008086543,-0.009088415,-0.031630546,0.020896198,-0.018749328,0.022613693,-0.014097777,0.004347411,0.014813401,-0.013525278,-0.001726441,0.010448099,0.036067411,-0.026048684,-0.020753073,-0.005045144,0.033348043,-0.002576244,0.02404494,0.022041194,0.017031832,-0.000297431,-0.003184523,-0.012738093,0.022756819,-0.016888708,0.021039322,-0.000313085,0.032203045,-0.011235285,0.001583316,-0.00461577,-0.026334934,-0.002934055,-0.005939673,0.001458082,0.007156232,-0.005689205,-0.042937394,0.011378409,0.007156232,0.00554608,0.026621183,-0.014455589,-0.017604331,-0.02647806,-0.03578116,-0.009804038,0.006905764,-0.0197512,-0.035494912,-0.027623056,-0.00461577,0.011521534,0.006905764,0.009517789,0.003112961,0.033920541,-0.004687332,-0.005045144,-0.009231539,0.000126911,0.008694822,-0.029340552,0.011163722,0.047517382,-0.039788652,-0.033348043,-0.003041399,-0.007657168,-0.035065539,-0.012165595,-0.024617439,0.0049378,0.017461207,0.029626802,-0.004723113,-0.000366757,-0.041792396,0.041219898,-0.009446226,0.016960271,-0.017747456,-0.036067411,0.025046812,0.027336806,0.025905561,0.049234878,0.016602458,-0.005796548,0.021325571,-0.003524444,-0.000872166,0.014670276,0.020323699,0.002737259,0.009660914,-0.006440609,-0.062402345,-0.062688597,-0.008158104,-0.018749328,0.005438737,-0.002066362,0.000205742,-0.018749328,0.017103394,-0.03578116,0.000265004,-0.03663991,-0.024760563,0.054101113,-0.00647639,-0.026334934,0.034779288,0.022756819,-0.033348043,-0.02433119,-0.041792396,-0.014455589,-0.023329318,-0.004687332,-0.013453716,-0.018319955,-0.014455589,0.043509893,0.013453716,-0.014813401,0.009052633,-0.034349915,0.052097369,-0.003774913,0.016316209,-0.027050557,0.028195554,-0.007549825,-0.020466823,0.014598713,-0.005939673,0.003273976,-0.052097369,0.002701478,-0.02404494,-0.005903892,0.009947163,-0.00043161,0.02189807,0.042078644,-0.020609949,0.007836075,0.018892452,0.001207614,0.009159978,-0.029197427,-0.023329318,0.004347411,-0.019464951,0.020180576,0.019894326,0.00615436,0.021468697,-0.017461207,-0.011879345,-0.002307885,0.016101522,-0.029626802,-0.014455589,0.020323699,0.020753073,0.018176829,-0.006082797,0.027766181,0.016530896,-0.008444354,0.001806949,0.029626802,-0.012451844,0.023186192,0.006869983,-0.034063663,-0.012094032,-0.021611821,-0.008050761,0.05581861,-0.004257958,-0.025333062,-0.004526317,0.018033706,0.027479932,0.025476186,0.008802165,-0.009589351,0.012809656,0.012523406,0.0400749,0.018033706,0.011020597,0.014956526,0.013883091,-0.006655296,0.019608077,-0.03234617,0.007585606,-0.036067411,-0.024617439,-0.001628043,0.022041194,0.026764309,-0.038643654,-0.009124196,-0.020323699,-0.013883091,0.02404494,0.002361557,-0.03234617,-0.0049378,0.018606203,0.022327444,0.043509893,-0.030485548,-0.003560225,0.007442481,0.00370335,0.011449971,0.023472441,0.000197915,-0.011950907,0.023329318,-0.009804038,-0.025619311,0.0074067,-0.003953818,0.014312465,0.048662379,-0.027193682,0.019894326,-0.042364895,0.003327648,0.042937394,-0.040933646,-0.020466823,0.056104861,0.020896198,-0.014527151,-0.036210533,-0.022470569,0.035924286,-0.013167467,-0.055532362,-0.006190141,-0.027909305,0.012881218,0.003005618,0.005689205,0.01109216,-0.016387772,-0.021468697,0.018176829,-0.021611821,0.032918669,0.002951946,-0.008837947,-0.031773672,-0.029913051,0.017318081,0.017461207,-0.02833868,-0.027479932,-0.023615567,0.037212405,-0.023615567,-0.02404494,0.029626802,0.002951946,0.004043271,-0.001377575,0.007800293,0.024188064,-0.027336806,-0.002361557,-0.00307718,-0.025189938,0.007192013,-0.000207978,0.040933646,0.010877473,-0.000720096,-0.006941545,0.003059289,0.032775544,-0.007657168,0.019321827,-0.012094032,0.042078644,-0.010591224,0.011807784,-0.016173085,-0.015529023,-0.023615567,0.016173085,-0.018606203,0.007192013,-0.008587479,0.000257177,0.002245268,-0.011879345,0.044082388,-0.005939673,-0.003059289,-0.013954652,-0.026621183,0.039502401,-0.006440609,0.014384027,0.012094032,-0.034779288,-0.002379447,0.023329318,0.029483676,-0.002325775,-0.001565426,0.025619311,0.018606203,-0.016101522,-0.0301993,0.002576244,0.035208661,0.002325775,-0.011664659,-0.022470569,-0.047231134,-0.016888708,-0.017747456,0.05152487,0.009374664,-0.010591224,0.009303101,-0.005009362,-0.029197427,0.001726441,-0.023758691,-0.002934055,-0.017461207,0.018606203,-0.002665696,-0.003578116,-0.018606203,-0.004651551,-0.021325571,0.005367174,-0.009124196,0.016888708,-0.01295278,0.002048471,-0.011593096,0.017604331,-0.008515916,0.006082797,-0.036067411,-0.027336806,-0.010018725,-0.001306012,0.026334934,-0.019321827,-0.030914923,-0.026764309,-0.0024689,-0.005581861,-0.002755149,0.019464951,-0.01295278,0.011163722,0.000639588,0.025476186,0.029483676,0.042651143,-0.011306847,0.002737259,0.010090288,-0.015600586,0.038357403,0.029197427,-0.008193886,0.044082388,0.032489292,-0.00123445,-0.008372792,0.009124196,-0.00309507,-0.041792396,0.007764512,-0.009947163,0.044941138,0.030056175,-0.013024342,-0.019321827,0.019321827,0.008551697,-0.053814866,0.038071156,-0.037784904,0.012165595,-0.008444354,-0.029626802,-0.006905764,-0.028195554,-0.01080591,-0.0098756,-0.032203045,0.040361151,-0.033920541,0.004454754,-0.036067411,0.011879345,-0.011235285,0.020609949,-0.004579989,0.0074067,-0.017103394,0.01789058,0.011449971,-0.007836075,0.000427138,-0.007120451,0.008337011,0.00123445,-0.003273976,-0.007263576,-0.011449971,0.022756819,0.002576244,-0.013310592,-0.013382155,-0.011664659,-0.013453716,-0.005152487,-0.050379876,-0.034636162,-0.011306847,0.015028087,0.008480135,-0.047517382,-0.00586811,-0.008301229,-0.01416934,0.000876638,0.000326503,0.01080591,0.004150615,0.005259831,-0.008837947,0.017031832,-0.016316209,-0.036210533,-0.013883091,-0.000295195,0.014240902,0.020753073,-0.022899942,-0.038929902,0.00586811,-0.008050761,0.00016437,-0.001932183,0.001789058,0.017031832,0.045227386,-0.016745584,-0.005689205,0.008372792,0.008301229,-0.016674021,-0.004222177,0.005832329,0.016173085,-0.009374664,-0.006869983,-0.052669868,0.035065539,0.000123557,0.007478263,0.033491168,0.054387365,0.002254213,-0.007836075,-0.020323699,-0.019178702,-0.010376536,-0.039788652,-0.032632418,-0.012380281,-0.002540462,-0.016602458,-0.022756819,0.019608077,0.001887456,0.032918669,0.008050761,-0.013739966,0.006547953,-0.016674021,0.001574371,0.019321827,-0.016960271,-0.031201173,0.027766181,0.006655296,0.020753073,0.009804038,0.024903689,-0.043509893,0.015815273,-0.017962143,-0.043223642,0.033920541,-0.007764512,-0.006762639,0.017819017,-0.026621183,0.046658635,-0.004490536,0.024188064,-0.010304974,0.004651551,0.047231134,-0.038071156,0.009589351,-0.033920541,-0.027050557,0.050093625,0.008515916,-0.025189938,-0.008050761,0.011950907,0.004973582,0.014527151,-0.009374664,-0.003721241,0.019608077,0.049807377,0.016602458,0.02404494];
  3. 파일을 저장하고 닫습니다.

2

터미널 창에서 mongosh 을 열고 클러스터에 연결합니다. 연결에 대한 자세한 지침은 mongosh 를 통해 클러스터에 연결을 참조하세요.

3

mongosh 프롬프트에서 다음 명령을 실행합니다.

use sample_mflix
switched to db sample_mflix
4

<path-to-file>embeddings.js 파일의 절대 경로로 바꾼 후 다음 명령을 실행하여 임베딩을 로드합니다.

load('/<path-to-file>/embeddings.js');

임베딩이 성공적으로 로드되었는지 확인하려면 다음 명령을 실행 .

STAR_WARS_EMBEDDING.length
2048
5
1db.embedded_movies.aggregate( [
2 {
3 $scoreFusion: {
4 input: {
5 pipelines: {
6 searchOne: [
7 {
8 "$vectorSearch": {
9 "index": "hybrid-vector-search",
10 "path": "plot_embedding_voyage_3_large",
11 "queryVector": STAR_WARS_EMBEDDING,
12 "numCandidates": 100,
13 "limit": 20
14 }
15 }
16 ],
17 searchTwo: [
18 {
19 "$search": {
20 "index": "hybrid-full-text-search",
21 "text": {
22 "query": "star wars",
23 "path": "title"
24 }
25 }
26 },
27 ]
28 },
29 normalization: "sigmoid"
30 },
31 combination: {
32 method: "expression",
33 expression: {
34 $sum: [
35 {$multiply: [ "$$searchOne", 10]}, "$$searchTwo"
36 ]
37 }
38 },
39 "scoreDetails": true
40 }
41 },
42 {
43 "$project": {
44 _id: 1,
45 title: 1,
46 plot: 1,
47 scoreDetails: {"$meta": "scoreDetails"}
48 }
49 },
50 { $limit: 10 }
51] )
[
{
_id: ObjectId('573a1397f29313caabce68f6'),
plot: "Luke Skywalker joins forces with a Jedi Knight, a cocky pilot, a wookiee and two droids to save the universe from the Empire's world-destroying battle-station, while also attempting to rescue Princess Leia from the evil Darth Vader.",
title: 'Star Wars: Episode IV - A New Hope',
scoreDetails: {
value: 7.847857250621068,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7987099885940552,
weight: 1,
value: 0.6896984675751023,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 2.9629626274108887,
weight: 1,
value: 0.950872574870045,
details: []
}
]
}
},
{
_id: ObjectId('573a139af29313caabcf0f5f'),
plot: 'Two Jedi Knights escape a hostile blockade to find allies and come across a young boy who may bring balance to the Force, but the long dormant Sith resurface to reclaim their old glory.',
title: 'Star Wars: Episode I - The Phantom Menace',
scoreDetails: {
value: 7.801513736063318,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7771433591842651,
weight: 1,
value: 0.6850641161193273,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 2.9629626274108887,
weight: 1,
value: 0.950872574870045,
details: []
}
]
}
},
{
_id: ObjectId('573a1397f29313caabce77d9'),
plot: 'After the rebels have been brutally overpowered by the Empire on their newly established base, Luke Skywalker takes advanced Jedi training with Master Yoda, while his friends are pursued by Darth Vader as part of his plan to capture Luke.',
title: 'Star Wars: Episode V - The Empire Strikes Back',
scoreDetails: {
value: 7.797042499608402,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7810181975364685,
weight: 1,
value: 0.6858995173201419,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 2.7174296379089355,
weight: 1,
value: 0.9380473264069833,
details: []
}
]
}
},
{
_id: ObjectId('573a13c0f29313caabd62f62'),
plot: 'Anakin Skywalker and Ahsoka Tano must rescue the kidnapped son of Jabba the Hutt, but political intrigue complicates their mission.',
title: 'Star Wars: The Clone Wars',
scoreDetails: {
value: 7.79454790938817,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7561323642730713,
weight: 1,
value: 0.6805134398691156,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 4.537533760070801,
weight: 1,
value: 0.989413510697013,
details: []
}
]
}
},
{
_id: ObjectId('573a1397f29313caabce8cdb'),
plot: 'After rescuing Han Solo from the palace of Jabba the Hutt, the rebels attempt to destroy the second Death Star, while Luke struggles to make Vader return from the dark side of the Force.',
title: 'Star Wars: Episode VI - Return of the Jedi',
scoreDetails: {
value: 7.7910863426550625,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7782549858093262,
weight: 1,
value: 0.6853039016248079,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 2.7174296379089355,
weight: 1,
value: 0.9380473264069833,
details: []
}
]
}
},
{
_id: ObjectId('573a139af29313caabcf124d'),
plot: 'As the Clone Wars near an end, the Sith Lord Darth Sidious steps out of the shadows, at which time Anakin succumbs to his emotions, becoming Darth Vader and putting his relationships with Obi-Wan and Padme at risk.',
title: 'Star Wars: Episode III - Revenge of the Sith',
scoreDetails: {
value: 7.743510743539187,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.756283700466156,
weight: 1,
value: 0.6805463417132204,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 2.7174296379089355,
weight: 1,
value: 0.9380473264069833,
details: []
}
]
}
},
{
_id: ObjectId('573a139af29313caabcf1258'),
plot: 'Ten years after initially meeting, Anakin Skywalker shares a forbidden romance with Padmè, while Obi-Wan investigates an assassination attempt on the Senator and discovers a secret clone army crafted for the Jedi.',
title: 'Star Wars: Episode II - Attack of the Clones',
scoreDetails: {
value: 7.708006822019003,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7400004267692566,
weight: 1,
value: 0.676995949561202,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 2.7174296379089355,
weight: 1,
value: 0.9380473264069833,
details: []
}
]
}
},
{
_id: ObjectId('573a1398f29313caabce9091'),
plot: "A Duke's son leads desert warriors against the galactic emperor and his father's evil nemesis when they assassinate his father and free their desert world from the emperor's rule.",
title: 'Dune',
scoreDetails: {
value: 6.888556969451009,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7947750091552734,
weight: 1,
value: 0.6888556969451008,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 0,
weight: 1,
value: 0
}
]
}
},
{
_id: ObjectId('573a1397f29313caabce6f53'),
plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...',
title: 'Message from Space',
scoreDetails: {
value: 6.8813100491486825,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7913960218429565,
weight: 1,
value: 0.6881310049148682,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 0,
weight: 1,
value: 0
}
]
}
},
{
_id: ObjectId('573a139df29313caabcfa90b'),
plot: 'In this Star Wars take-off, the peaceful planet of Jillucia has been nearly wiped out by the Gavanas, whose leader takes orders from his mother (played a comic actor in drag) rather than ...',
title: 'Message from Space',
scoreDetails: {
value: 6.8813100491486825,
description: 'the value calculated by combining the scores (either normalized or raw) across input pipelines from which this document is output from:',
normalization: 'sigmoid',
combination: {
method: 'custom expression',
expression: "{ string: { $sum: [ { $multiply: [ '$$searchOne', 10 ] }, '$$searchTwo' ] } }"
},
details: [
{
inputPipelineName: 'searchOne',
inputPipelineRawScore: 0.7913960218429565,
weight: 1,
value: 0.6881310049148682,
details: []
},
{
inputPipelineName: 'searchTwo',
inputPipelineRawScore: 0,
weight: 1,
value: 0
}
]
}
}
]

샘플 쿼리 시맨틱 및 전체 텍스트 검색에서 점수가 매겨진 검색 결과를 조회하고 sigmoid 표현식 적용하여 결과를 결합하기 전에 점수를 정규화합니다. 그런 다음 파이프라인의 점수를 각 문서 에 대한 단일 집계 점수로 결합합니다.

샘플 쿼리 결과를 결합할 때 정규화된 입력 파이프라인 점수에 가중치를 적용합니다. 사용자 지정 집계 표현식 사용하여 가중치를 적용합니다. 이 예시 에서 쿼리 $multiply 표현식 사용하여 searchOne 파이프라인 의 점수에 10를 곱합니다. 이렇게 하면 이 파이프라인 의 결과가 searchTwo 파이프라인 의 결과보다 최종 점수에 더 많이 기여하게 됩니다. 그런 다음 $sum 집계 연산자 사용하여 두 파이프라인 단계의 점수를 더합니다.

Final Score = ($$searchOne * 10) + $$searchTwo

참고

표현식 (combination.method: expression)을 사용하여 쿼리 결과를 결합하는 경우 쿼리 에 가중치를 사용할 수 없습니다. 앞의 샘플 쿼리 에 설명된 대로 $multiply 를 사용하는 것이 좋습니다.

샘플 쿼리 $scoreFusion 단계를 사용하여 시맨틱 및 전체 텍스트 쿼리를 독립적으로 실행한 다음 입력 쿼리 결과를 중복 제거하고 결합하여 최종 점수 결과 설정하다 로 결합합니다. 입력 파이프라인의 합산 점수와 조합 가중치를 기반으로 문서 설정하다 반환합니다. 구체적으로 이 단계에서는 다음과 같은 입력 파이프라인을 사용합니다.

vectorPipeline

이 파이프라인 에는 $vectorSearch 쿼리 포함되어 있습니다. 필드 plot_embedding_voyage_3_large 에서 쿼리 필드 에서 벡터 임베딩으로 지정된 Starwars queryVector 문자열을 검색합니다. 쿼리 필드 의 voyage-3-large 임베딩에 사용된 것과 동일한 모델인Voyage AI 의 임베딩 모델을 plot_embedding_voyage_3_large 사용합니다. 또한 쿼리 100 최대 개의 가장 가까운 이웃에 대한 검색 지정하고 결과를 20 개의 문서로만 제한합니다. 이 단계에서는 시맨틱 검색 에서 점수가 매겨진 문서를 반환합니다.

fullTextPipeline

이 파이프라인에는 다음 단계가 포함됩니다.

  • 를 입력하여 필드 에 이라는$search 텀 포함된 영화를 검색 star wars title . 이 단계에서는 Full Text 검색 에서 점수가 매겨진 문서를 반환합니다.

  • $limit를 사용하여 $search 단계의 출력을 20개 결과로만 제한합니다.

샘플 쿼리 다음 단계를 사용하여 시맨틱 및 텍스트 검색 결과를 점수가 매겨진 단일 문서 목록으로 반환합니다.

결과에 다음 필드만 포함합니다.

  • _id

  • title

  • plot

  • scoreDetails

출력을 10 결과로만 제한합니다.

돌아가기

하이브리드 검색

이 페이지의 내용