Vector indexes
Node vector indexes were released as a public beta in Neo4j 5.11 and general availability in Neo4j 5.13.
Vector indexes enable similarity searches and complex analytical queries by representing nodes or properties as vectors in a multidimensional space.
The following resources provide hands-on tutorials for working with LLMs and vector indexes in Neo4j:
Neo4j vector indexes are powered by the Apache Lucene indexing and search library.[1]
Example graph
The examples on this page use the Neo4j movie recommendations dataset, focusing on the plot
and embedding
properties of Movie
nodes.
The embedding
property consists of a 1536-dimension vector embedding of the plot
and title
property combined.
The graph contains 28863 nodes and 332522 relationships.
To recreate the graph, download and import this dump file to an empty Neo4j database (running version 5.13 or later). Dump files can be imported for both Aura and on-prem instances.
The dump file used to load the dataset contains embeddings generated by OpenAI, using the model text-embedding-ada-002 .
|
Vectors and embeddings in Neo4j
Vector indexes allow you to query vector embeddings from large datasets. An embedding is a numerical representation of a data object, such as a text, image, or document. Each word or token in a text is typically represented as high-dimensional vector where each dimension represents a certain aspect of the word’s meaning.
The embedding for a particular data object can be created by both proprietary (such as Vertex AI or OpenAI) and open source (such as sentence-transformers) embedding generators, which can produce vector embeddings with dimensions such as 256, 768, 1536, and 3072.
In Neo4j, vector embeddings are stored as LIST<INTEGER | FLOAT>
properties on a node or relationship.
For information about how embeddings can be generated and stored as properties, see: |
For example, the movie The Godfather, has the following plot
: "The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son."
This is its 1536-dimensional embedding
property, where each element in the LIST
represents a particular aspect of the plot’s meaning:
[0.005967312026768923, -0.03817005082964897, 0.0014667075593024492, -0.03868866711854935, -0.006505374796688557, 0.020900176838040352, -0.0027551413513720036, -0.0024731445591896772, -0.03734026849269867, -0.02228747308254242, 0.028783122077584267, 0.017905177548527718, 0.011396560817956924, 0.014235977083444595, 0.023143187165260315, -0.014184115454554558, 0.029846282675862312, -0.011928141117095947, 0.018838683143258095, -0.0019172541797161102, 0.0033483069855719805, 0.009497134014964104, -0.03516208380460739, 0.0021441481076180935, 0.002657901030033827, 0.0030760341323912144, 0.004255882930010557, -0.020809419453144073, 0.02358401007950306, -0.013808120042085648, 0.01064456906169653, -0.006975369527935982, 0.007318951655179262, -0.013872946612536907, 0.005905726458877325, -0.010689947754144669, 0.0020225979387760162, -0.016245609149336815, -0.00038815077277831733, -0.007163367234170437, 0.027668101713061333, 0.007215228863060474, -0.009380445815622807, -0.02956104464828968, -0.000863007502630353, 0.012142069637775421, 0.0012957267463207245, -0.027953339740633965, -0.016414159908890724, 0.008453421294689178, -0.0010777463903650641, 0.03311355784535408, -0.013639570213854313, -0.052457891404628754, 0.0010242642601951957, 0.0034390646032989025, -0.01049546804279089, 0.006456754636019468, 0.003970644902437925, -0.011629937216639519, 0.005280147306621075, -0.023402493447065353, -0.014689764939248562, -0.007623638026416302, -0.002453696448355913, 0.02290981076657772, 0.0017989451298490167, 0.0013427261728793383, -0.001776255783624947, -0.002414800226688385, 0.04833490028977394, 0.031142819672822952, -0.0033013075590133667, 0.017879245802760124, 0.0070077828131616116, -0.016154851764440536, -0.005772831384092569, 0.019875913858413696, -0.018008900806307793, 0.012764407321810722, 0.0055232481099665165, -0.027901478111743927, -0.0034909259993582964, 0.0307279285043478, 0.006472961511462927, 0.008861830458045006, -0.01802186481654644, 0.018281172960996628, -0.014223011210560799, -0.00018313586770091206, 0.0026352116838097572, 0.0006754148053005338, 0.014975002966821194, 0.024361930787563324, -0.017166150733828545, 0.0028880364261567593, 0.011824417859315872, 0.01710132323205471, -0.0005003822734579444, -0.018890544772148132, -0.002192768268287182, -0.0018264965619891882, 0.011033530347049236, -0.009095207788050175, -0.022689398378133774, -0.004281813744455576, 0.007092057727277279, -0.015247276052832603, 0.024115590378642082, 0.002996621420606971, -0.02834230102598667, 0.030546413734555244, 0.02350621670484543, -0.020511215552687645, 0.010190781205892563, -0.016582708805799484, 0.028238577768206596, -0.011967036873102188, 0.011623455211520195, -0.02797926962375641, 0.0026254875119775534, 0.018307102844119072, 0.0038701631128787994, -0.03850715234875679, 0.006246067117899656, -0.0006312514888122678, 0.010352848097682, -0.02358401007950306, -0.026708664372563362, -0.002863726345822215, 0.035862214863300323, 0.009860164485871792, -0.01726987399160862, 0.004275330808013678, -0.02663087099790573, 0.009140586480498314, -0.013872946612536907, 0.019136887043714523, -0.020835351198911667, -0.0250879917293787, 0.03044269047677517, 0.026280807331204414, -0.013406192883849144, 0.006683648563921452, -0.01216800045222044, 0.007824601605534554, 0.031505849212408066, 0.023726629093289375, 0.0294832531362772, -0.013678465969860554, 0.033891480416059494, 0.009211895987391472, 0.017088359221816063, -0.02183368429541588, 0.01847565360367298, 0.004644844215363264, -0.009834233671426773, -0.011344699189066887, -0.0006725785788148642, 0.00012691882147919387, 0.015338033437728882, 0.025736261159181595, -0.003967403434216976, -0.007312469184398651, -0.01312743779271841, 0.02350621670484543, -0.0006843284936621785, -0.011785522103309631, 0.006570201832801104, -0.004187814891338348, -0.0070013003423810005, 0.0165178831666708, -0.004537879955023527, 0.022715330123901367, -0.0025120405480265617, 0.025580676272511482, 0.005053253378719091, -0.0020063910633325577, -0.039285074919462204, -0.001816772622987628, 0.0007224142318591475, 0.0161029901355505, 0.04086684808135033, 0.03536953032016754, 0.009626788087189198, -0.023571044206619263, -0.009607339277863503, 0.011085391975939274, 0.020835351198911667, -0.0009027139167301357, -0.007584741804748774, 0.016958704218268394, 0.011130770668387413, -0.016829051077365875, -0.6712950468063354, -0.006511857267469168, -0.024854615330696106, -0.02663087099790573, -0.00008933950448408723, 0.0061779990792274475, 0.004605947993695736, 0.013231161050498486, -0.020187081769108772, 0.00798666849732399, -0.001847565290518105, 0.04086684808135033, 0.007519915234297514, 0.0040808506309986115, -0.034021131694316864, -0.01997963711619377, -0.004972219467163086, -0.023220978677272797, 0.012129104696214199, 0.0018329792656004429, -0.011649386025965214, 0.028446022421121597, -0.0010356089333072305, -0.006223377771675587, 0.021211346611380577, 0.004006299655884504, 0.021937407553195953, -0.02927580662071705, -0.01129283756017685, -0.009296170435845852, -0.01864420250058174, 0.02717541716992855, -0.0003555347793735564, 0.0021700789220631123, 0.048360832035541534, -0.002277043182402849, -0.009049829095602036, 0.033969271928071976, 0.004557327833026648, 0.018916476517915726, -0.000779542897362262, -0.00638544512912631, 0.022183749824762344, -0.012757924385368824, -0.027149485424160957, -0.012278205715119839, 0.0238303504884243, -0.02963883802294731, 0.005218561738729477, -0.004434156697243452, 0.013665501028299332, -0.0024520757142454386, 0.002124700229614973, -0.007273572962731123, -0.0035654769744724035, -0.0028621056117117405, 0.020640870556235313, 0.01091684214770794, -0.0006867594784125686, -0.011694764718413353, 0.011215046048164368, 0.016504917293787003, 0.00827838946133852, -0.0044471221044659615, 0.010676982812583447, 0.027771824970841408, -0.0133802630007267, 0.029820352792739868, 0.008349698968231678, -0.014573076739907265, -0.009017415344715118, 0.011655868031084538, -0.0061066895723342896, -0.013082059100270271, 0.004353123251348734, 0.00672254478558898, 0.01773662678897381, 0.012433790601789951, 0.023843316361308098, 0.015221345238387585, -0.0046221548691391945, -0.00026214358513243496, -0.016582708805799484, 0.016504917293787003, 0.028005201369524002, 0.005516765173524618, -0.04309689253568649, 0.013743292540311813, -0.0064308238215744495, -0.007176332641392946, 0.01911095716059208, 0.00446332897990942, -0.012971853837370872, -0.016919808462262154, 0.010048162192106247, 0.0032769974786788225, -0.021548446267843246, 0.001816772622987628, 0.01856641098856926, -0.04804966226220131, 0.007286538369953632, -0.007299503777176142, -0.014080392196774483, 0.008952588774263859, 0.023908143863081932, 0.012932957150042057, -0.008433973416686058, 0.012783855199813843, 0.0430709607899189, -0.01015836838632822, 0.03534360229969025, -0.007584741804748774, -0.016453055664896965, -0.005720969755202532, -0.014871280640363693, -0.026540113613009453, 0.005228285677731037, 0.0004019264888484031, 0.005931657273322344, -0.02533433400094509, -0.018825719133019447, 0.0023353875149041414, 0.0014059323584660888, -0.02020004764199257, 0.022481953725218773, 0.034980569034814835, -0.02709762565791607, -0.022974636405706406, -0.025023166090250015, 0.00641785841435194, -0.00019822835747618228, -0.004845807328820229, 0.0003723492263816297, -0.010132437571883202, 0.01498796883970499, 0.001948046963661909, -0.0020161152351647615, -0.008842382580041885, 0.0223652645945549, -0.013574742712080479, -0.002369421534240246, 0.003275376744568348, 0.005879795644432306, 0.005789037793874741, 0.006359514314681292, -0.03549918532371521, 0.003118171589449048, -0.026993902400135994, -0.01614188589155674, 0.011578075587749481, 0.0008524731383658946, -0.013367297127842903, 0.004194297362118959, 0.019331367686390877, 0.006152068264782429, -0.015208380296826363, -0.0018005658639594913, -0.015714028850197792, -0.01681608520448208, -0.028990568593144417, 0.010676982812583447, 0.024595309048891068, -0.045560311526060104, -0.0009262136882171035, 0.014845349825918674, -0.020887212827801704, 0.015739960595965385, 0.011727177537977695, 0.0012560202740132809, -0.023052429780364037, 0.0014245701022446156, -0.013062611222267151, -0.011299320496618748, 0.022274507209658623, 0.011338216252624989, -0.007908876053988934, 0.010339883156120777, -0.006132620386779308, 0.01247916929423809, -0.007947771809995174, -0.0025347298942506313, -0.011416008695960045, 0.011027047410607338, 0.004521673079580069, 0.04880165681242943, 0.0012543996563181281, 0.02115948498249054, 0.0165178831666708, -0.025373229756951332, 0.026125222444534302, -0.0031262750271707773, 0.007669016718864441, 0.003821542952209711, -0.021561412140727043, 0.008187631145119667, 0.02358401007950306, 0.02249491773545742, 0.015247276052832603, -0.004560569301247597, 0.030753860250115395, 0.031090958043932915, -0.021457688882946968, 0.027694031596183777, -0.004823117982596159, 0.0049171168357133865, -0.018346000462770462, -0.0030355174094438553, -0.011176149360835552, 0.024102624505758286, 0.006923507899045944, 0.010009266436100006, -0.00510187353938818, 0.0007916979375295341, -0.004722636193037033, 0.019914809614419937, 0.026190048083662987, -0.013289504684507847, 0.006346548907458782, -0.015415825881063938, -0.026734594255685806, 0.003623821074143052, 0.005325525999069214, -0.003922024741768837, -0.00640813447535038, -0.014624938368797302, -0.0065021333284676075, 0.007435640320181847, -0.002808623481541872, 0.010138919577002525, -0.033813685178756714, -0.0032008260022848845, 0.01614188589155674, -0.018994268029928207, 0.008135770447552204, -0.008596041239798069, -0.015662167221307755, 0.004310985561460257, -0.014663834124803543, 0.014962038025259972, -0.03479905426502228, 0.013114472851157188, 0.01341915875673294, 0.05092797800898552, -0.011908693239092827, 0.005332008935511112, -0.013367297127842903, 0.02501020021736622, -0.00029678543796762824, -0.02454344742000103, 0.003152205841615796, -0.015454721637070179, 0.010028714314103127, -0.02102983184158802, -0.0032624113373458385, 0.03583628311753273, -0.015026864595711231, 0.00672254478558898, 0.000010907877367571928, 0.019875913858413696, 0.020161151885986328, 0.014054462313652039, -0.005675591062754393, -0.009224860928952694, 0.014793488197028637, 0.03687351569533348, -0.005442214198410511, 0.005633453372865915, -0.0030436208471655846, -0.012615305371582508, -0.009075759910047054, 0.017192082479596138, -0.002220319816842675, 0.005798762198537588, -0.0007568534929305315, 0.010378778912127018, 0.005908967927098274, -0.0158825796097517, 0.0088812792673707, 0.007766257040202618, -0.0030209312681108713, -0.013561777770519257, -0.035395462065935135, 0.022391194477677345, -0.0027049004565924406, 0.004748567007482052, -0.020433424040675163, -0.00028706141165457666, -0.005092149134725332, -0.018371930345892906, 0.006009449250996113, -0.00645027169957757, 0.015286171808838844, -0.012343033216893673, -0.008628454059362411, -0.010605673305690289, 0.009192448109388351, 0.007500466890633106, -0.013535846956074238, 0.003831267124041915, -0.02956104464828968, 0.0009724028059281409, 0.0034585127141326666, -0.00004074468961334787, -0.025139853358268738, 0.012278205715119839, 0.023519182577729225, -0.012913509272038937, -0.006301170215010643, 0.0037178201600909233, 0.004716153722256422, -0.017905177548527718, 0.009769407100975513, -0.019746258854866028, -0.011675315909087658, 0.007409709505736828, -0.022676432505249977, -0.013406192883849144, 0.003922024741768837, 0.03925914317369461, -0.011325251311063766, -0.014611972495913506, -0.022404160350561142, -0.03311355784535408, 0.0024634203873574734, 0.1057974249124527, 0.014145219698548317, 0.025956671684980392, 0.006878129206597805, -0.019914809614419937, -0.019162818789482117, -0.009231343865394592, -0.04423784464597702, 0.012018898501992226, -0.00921837892383337, 0.02408965863287449, -0.026501217857003212, 0.020225977525115013, 0.005014357157051563, 0.02053714729845524, 0.014521215111017227, -0.002670866437256336, -0.020433424040675163, -0.0015372068155556917, -0.031168751418590546, 0.0051213214173913, 0.006865163799375296, 0.010048162192106247, 0.003795612370595336, -0.009749959222972393, -0.024063728749752045, 0.026449356228113174, 0.00967864878475666, -0.009049829095602036, -0.012284688651561737, -0.02475089207291603, 0.0034844432957470417, -0.00928320549428463, 0.011772556230425835, -0.01811262220144272, -0.01918874867260456, 0.009043346159160137, 0.023843316361308098, 0.02580108679831028, 0.005980277433991432, 0.029327668249607086, -0.008103356696665287, 0.008083908818662167, -0.005490834359079599, 0.021146519109606743, -0.0023499734234064817, -0.03298390284180641, 0.005283388774842024, -0.00043352958164177835, -0.024271173402667046, 0.03181701898574829, -0.000028944177756784484, -0.004479535389691591, -0.002066355897113681, 0.017995934933423996, -0.012783855199813843, 0.013859981670975685, -0.006615580525249243, -0.0008403180981986225, 0.025489918887615204, -0.01789221167564392, -0.03189481049776077, 0.00028949242550879717, -0.03251715004444122, 0.03588814660906792, -0.03500650078058243, -0.007869980297982693, -0.024361930787563324, 0.00451519014313817, -0.018177449703216553, 0.020627904683351517, 0.003249445930123329, 0.010962220840156078, -0.005299595184624195, 0.048023734241724014, -0.0033094107639044523, 0.012971853837370872, -0.02290981076657772, 0.017918141558766365, -0.016245609149336815, -0.013179299421608448, -0.020589008927345276, 0.0037469922099262476, -0.029327668249607086, -0.007383778691291809, 0.013017232529819012, 0.006327101029455662, -0.02689017914235592, -0.004385536536574364, 0.005789037793874741, -0.005597798619419336, -0.004152160137891769, 0.012719028629362583, -0.008220044896006584, -0.01702353172004223, -0.011506766080856323, 0.0042980206198990345, 0.0018702547531574965, -0.0032964455895125866, 0.007267090491950512, -0.009581409394741058, -0.0058182100765407085, -0.005429248791188002, -0.008829417638480663, -0.0030403793789446354, -0.01194110605865717, -0.002591453492641449, 0.005756624508649111, -0.01618078351020813, -0.009821268729865551, -0.00021210535487625748, -0.01768476516008377, -0.0005562954465858638, -0.017451388761401176, -0.015545479021966457, 0.02332470193505287, 0.015960371121764183, 0.02208002656698227, 0.01369143184274435, -0.014495284296572208, -0.007701430004090071, -0.0005567006301134825, 0.027590308338403702, 0.05188741534948349, -0.023609939962625504, -0.017957039177417755, 0.015999266877770424, -0.020900176838040352, 0.003038758644834161, 0.021042795851826668, -0.009814785793423653, 0.0014083633432164788, 0.010897394269704819, -0.0167253278195858, -0.020135220140218735, -0.005273664370179176, -0.009788854978978634, -0.002986897248774767, -0.008764590136706829, -0.006729027256369591, -0.018449721857905388, -0.009166517294943333, -0.002651418326422572, 0.008245975710451603, 0.0034358231350779533, -0.028757192194461823, 0.01511762198060751, -0.008544179610908031, 0.005344973877072334, 0.013924808241426945, -0.003299686824902892, -0.04143732413649559, -0.0008403180981986225, 0.010949255898594856, -0.013600673526525497, -0.03448788449168205, -0.007863497361540794, -0.01809965819120407, -0.00444063963368535, 0.004920358303934336, 0.0330357663333416, -0.008816451765596867, 0.006683648563921452, 0.00823301076889038, -0.015947405248880386, 0.02608632668852806, 0.0037243026308715343, -0.007623638026416302, -0.028031131252646446, 0.027123555541038513, 0.01843675784766674, 0.016712361946702003, 0.040374163538217545, -0.0021538722794502974, 0.01885164901614189, -0.011740143410861492, 0.017490284517407417, -0.0004517621418926865, -0.00034439266892150044, -0.026190048083662987, -0.021729961037635803, 0.0020209772046655416, -0.014521215111017227, -0.01467679999768734, 0.002505557844415307, -0.01061863824725151, 0.015623271465301514, -0.010087057948112488, -0.0031748951878398657, 0.01631043665111065, 0.016375262290239334, -0.013257091864943504, 0.010741809383034706, -0.012932957150042057, -0.002484489232301712, 0.0027324517723172903, 0.00897203665226698, -0.004793945699930191, 0.0043466403149068356, -0.0020047705620527267, 0.0021538722794502974, 0.021263208240270615, -0.0269679706543684, -0.024115590378642082, -0.0025833500549197197, 0.030598275363445282, 0.002772968728095293, 0.01584368385374546, 0.006981851998716593, -0.0037113374564796686, -0.01273199450224638, -0.026280807331204414, -0.02182071842253208, -0.049527715891599655, 0.02195037342607975, -0.008628454059362411, -0.004353123251348734, 0.01064456906169653, -0.009698097594082355, -0.04094463959336281, 0.0238303504884243, 0.0034649954177439213, 0.032802388072013855, 0.0002048123424174264, 0.022507883608341217, 0.03770329803228378, -0.010346366092562675, 0.0028588641434907913, 0.026410460472106934, 0.019085025414824486, 0.008848865516483784, 0.015830717980861664, -0.004469811450690031, 0.013808120042085648, -0.012031864374876022, -0.02099093608558178, -0.006054827943444252, -0.045638103038072586, -0.024050762876868248, 0.014417491853237152, 0.01218744833022356, 0.0032413427252322435, -0.013302470557391644, -0.0003156257444061339, 0.006942956242710352, 0.00542600778862834, -0.0034358231350779533, 0.022067060694098473, -0.013847015798091888, -0.026942040771245956, -0.0334506556391716, -0.01835896447300911, -0.0021036313846707344, -0.001962633104994893, 0.012615305371582508, -0.0186053067445755, 0.01572699472308159, -0.02542509138584137, 0.019422125071287155, -0.013950739055871964, -0.002110114088281989, 0.02052418142557144, -0.0014197081327438354, 0.0010485743405297399, -0.004372571129351854, 0.0069299908354878426, -0.005105114541947842, -0.003756716148927808, -0.015960371121764183, 0.025554746389389038, 0.003516856813803315, 0.005951105151325464, 0.009736993350088596, 0.043459922075271606, -0.008952588774263859, 0.021315069869160652, -0.011318768374621868, -0.016375262290239334, -0.004560569301247597, -0.026656802743673325, 0.004842565860599279, 0.0004894427256658673, -0.023635871708393097, 0.007448605261743069, -0.008965553715825081, 0.0026092808693647385, -0.01999260112643242, -0.007811635732650757, 0.012142069637775421, -0.01375625841319561, -0.02102983184158802, -0.006806819699704647, 0.015869613736867905, -0.0074032265692949295, -0.001892944099381566, -0.0037016132846474648, -0.005322284530848265, 0.03293204307556152, -0.014430457726120949, 0.0418262854218483, -0.012641236186027527, 0.018216345459222794, -0.028290439397096634, 0.02576219104230404, 0.008433973416686058, 0.013963703997433186, 0.030598275363445282, -0.01225227490067482, 0.012051312252879143, 0.0014553628861904144, -0.008822934702038765, 0.01100111659616232, 0.009860164485871792, -0.004388778004795313, -0.01685498282313347, 0.01091035921126604, -0.00033223762875422835, -0.007850532419979572, -0.0006320617976598442, 0.002114976057782769, -0.007532880175858736, 0.01710132323205471, 0.015610306523740292, -0.009036863222718239, 0.008200597018003464, 0.012174483388662338, 0.00447305291891098, 0.0186053067445755, -0.019253576174378395, 0.010638087056577206, -0.02086128108203411, 0.022404160350561142, 0.010437123477458954, 0.0006920266896486282, -0.02128913812339306, -0.009296170435845852, -0.004106780979782343, 0.044808320701122284, -0.013782189227640629, -0.003750233445316553, -0.01181145291775465, 0.02764216996729374, 0.011960554867982864, -0.005043528974056244, 0.006155309733003378, -0.015584375709295273, 0.012433790601789951, -0.021600307896733284, -0.04314875230193138, -0.01214855257421732, -0.024776823818683624, 0.039077628403902054, 0.016271540895104408, 0.000348039175150916, -0.01511762198060751, 0.0014926382573321462, -0.04068533331155777, -0.0020290804095566273, -0.006904060021042824, 0.02099093608558178, 0.017049461603164673, -0.006981851998716593, 0.007364330347627401, 0.007416191976517439, 0.00766253424808383, 0.02153548039495945, -0.002995000686496496, 0.02157437615096569, -0.011312286369502544, -0.009685131721198559, 0.00414891866967082, -0.009672166779637337, -0.01308854203671217, -0.003380720503628254, -0.003168412484228611, 0.013769223354756832, -0.012615305371582508, 0.007973702624440193, 0.001315985107794404, -0.006139102857559919, -0.028212646022439003, 0.0004906582762487233, 0.0006340876570902765, 0.013289504684507847, -0.010359331034123898, -0.02956104464828968, 0.0263456329703331, 0.02621597982943058, 0.005357939284294844, -0.022754225879907608, -0.009393410757184029, 0.007053161505609751, -0.018086692318320274, -0.0012552099069580436, 0.003977127373218536, -0.010839049704372883, -0.01584368385374546, 0.007753291632980108, 0.005951105151325464, 0.02478978969156742, -0.00858955830335617, 0.007280055433511734, 0.013257091864943504, -0.0000065713156800484285, 0.007234676741063595, -0.00413919473066926, -0.01467679999768734, -0.018333034589886665, -0.017658835276961327, -0.01681608520448208, 0.005108356010168791, -0.007630120497196913, 0.008479352109134197, -0.02771996334195137, 0.004567051772028208, -0.018579376861453056, -0.003983610309660435, -0.0023110774345695972, 0.023065393790602684, 0.04281165450811386, -0.015273206867277622, -0.006696613971143961, 0.002272181212902069, -0.008356180973351002, -0.014508250169456005, -0.0066090975888073444, 0.00827838946133852, -0.016906842589378357, 0.003750233445316553, -0.008524730801582336, -0.0022802846506237984, -0.005156976170837879, -0.009633270092308521, -0.035940006375312805, -0.004323950968682766, 0.027771824970841408, 0.19261354207992554, -0.014547145925462246, -0.006657717749476433, 0.013808120042085648, -0.021340999752283096, 0.011869796551764011, 0.024115590378642082, 0.014080392196774483, 0.0023856281768530607, 0.0005133476224727929, -0.016206713393330574, 0.01723097823560238, 0.008012599311769009, 0.0019723570439964533, 0.006560477428138256, -0.040996503084897995, -0.010657534934580326, 0.00037032339605502784, -0.027875546365976334, -0.011727177537977695, -0.00768198212608695, -0.007299503777176142, -0.011202080175280571, -0.01939619518816471, 0.039622172713279724, -0.011668833903968334, -0.015830717980861664, 0.016919808462262154, 0.03207632899284363, 0.015960371121764183, -0.01093629002571106, -0.016842016950249672, -0.008336733095347881, -0.013244125992059708, -0.011999450623989105, -0.020122256129980087, -0.007422674912959337, -0.02501020021736622, -0.008505282923579216, -0.005526489112526178, -0.0011830900330096483, 0.01773662678897381, 0.010709396563470364, -0.007267090491950512, 0.015999266877770424, 0.02604742906987667, -0.013315435498952866, 0.01621967926621437, -0.02082238532602787, -0.01689387857913971, -0.0439007468521595, -0.03358031064271927, 0.000994281843304634, 0.03726247698068619, -0.02208002656698227, 0.000011990435268671717, 0.006949438713490963, 0.020433424040675163, 0.00515373470261693, -0.031298406422138214, 0.0031116888858377934, 0.015701064839959145, -0.02813485451042652, -0.007377295754849911, 0.007461570668965578, 0.03985555097460747, -0.010975186713039875, -0.025697365403175354, 0.0397258959710598, -0.026319703087210655, -0.0030403793789446354, -0.010067610070109367, -0.002486109733581543, -0.0088812792673707, 0.0017438423819839954, -0.001923736883327365, 0.017827384173870087, 0.006220136769115925, 0.010255607776343822, 0.001199296792037785, -0.01772366091609001, 0.035136155784130096, -0.0061066895723342896, -0.010735327377915382, -0.010651051998138428, -0.026151152327656746, 0.006981851998716593, 0.006622062996029854, -0.010048162192106247, -0.0009124379721470177, -0.00419105589389801, -0.019668467342853546, 0.00012296844215597957, 0.004894427489489317, 0.006852198392152786, 0.010437123477458954, 0.005908967927098274, 0.0038247844204306602, -0.008103356696665287, -0.006456754636019468, -0.028653468936681747, 0.018216345459222794, 0.032205980271101, 0.00022101905778981745, -0.029664767906069756, -0.008155218325555325, 0.03871459513902664, 0.03394334018230438, 0.005860347766429186, -0.013600673526525497, -0.016958704218268394, 0.006372479721903801, 0.0012543996563181281, -0.01911095716059208, -0.010437123477458954, 0.008356180973351002, -0.012855164706707, -0.008472870104014874, 0.019370263442397118, -0.029457321390509605, 0.0034487885423004627, -0.015415825881063938, -0.00047364120837301016, 0.008887761272490025, -0.0020015290938317776, 0.010501950047910213, -0.007500466890633106, -0.0017470837337896228, 0.01717911660671234, -0.024063728749752045, 0.026734594255685806, -0.024556411430239677, 0.0013573121977970004, -0.00010007645323639736, -0.00450546620413661, 0.007513432297855616, 0.027201347053050995, 0.003426099196076393, -0.022183749824762344, 0.002813485451042652, 0.008064460940659046, 0.002243009163066745, 0.009899060241878033, 0.010988151654601097, -0.004790704697370529, -0.004638361278921366, 0.006025656126439571, -0.010605673305690289, -0.01625857502222061, -0.020342666655778885, -0.016090024262666702, -0.026410460472106934, 0.0121226217597723, -0.009406376630067825, 0.0023759042378515005, -0.0273828636854887, -0.015260240994393826, -0.004832841921597719, -0.0007702240254729986, 0.01856641098856926, -0.031039098277688026, 0.0073967440985143185, 0.018721995875239372, -0.023026498034596443, -0.008200597018003464, -0.023480286821722984, -0.16450461745262146, 0.025710329413414, 0.01681608520448208, -0.009023898281157017, 0.023428425192832947, -0.022754225879907608, 0.027616240084171295, 0.015234310179948807, -0.009224860928952694, 0.005166700109839439, 0.0008131718495860696, 0.0038507150020450354, -0.03153178095817566, -0.0026757284067571163, 0.003335341578349471, 0.00672254478558898, -0.030546413734555244, 0.036277107894420624, 0.017256908118724823, 0.0010526260593906045, 0.0053125605918467045, -0.02091314271092415, -0.0016555157490074635, -0.0012454859679564834, 0.023467320948839188, 0.009497134014964104, 0.0046351198107004166, 0.005380628630518913, -0.021691065281629562, -0.013062611222267151, -0.048023734241724014, -0.0008427490829490125, 0.017321735620498657, 0.021340999752283096, 0.011740143410861492, 0.012219862081110477, -0.012984818778932095, 0.007020748220384121, -0.015130587853491306, -0.016193747520446777, 0.0071439193561673164, 0.03236156702041626, 0.024997234344482422, 0.01185683161020279, 0.010735327377915382, 0.04636416584253311, 0.014599007554352283, -0.009004450403153896, 0.019383229315280914, -0.009607339277863503, -0.00414891866967082, -0.008336733095347881, -0.019888877868652344, -0.0005830365116707981, 0.02771996334195137, 0.005620488431304693, -0.00701426574960351, 0.013730327598750591, 0.014145219698548317, 0.011331734247505665, -0.021807754412293434, 0.022857949137687683, 0.01593444123864174, -0.0031343784648925066, 0.001282761339098215, -0.028627539053559303, 0.013354332186281681, 0.0034098925534635782, -0.014689764939248562, -0.004784221760928631, -0.015208380296826363, -0.00796722061932087, -0.008693280629813671, -0.02311725541949272, 0.011629937216639519, -0.012323584407567978, -0.03243935853242874, 0.007643085904419422, 0.00766253424808383, 0.0028702090494334698, -0.017412493005394936, 0.026267841458320618, 0.010884428396821022, -0.03448788449168205, 0.004327192436903715, 0.018838683143258095, -0.02228747308254242, -0.014702730812132359, -0.01020374707877636, -0.027694031596183777, 0.006122896447777748, -0.004252641461789608, -0.012686614878475666, -0.008829417638480663, 0.03319134935736656, 0.01789221167564392, 0.021250242367386818, -0.006683648563921452, 0.009412859566509724, -0.02294870652258396, 0.0009659201023168862, -0.008336733095347881, -0.019603639841079712, -0.012116138823330402, 0.009775889106094837, 0.03993334248661995, 0.009892578236758709, 0.017153184860944748, 0.015545479021966457, -0.01288109552115202, -0.020433424040675163, 0.013652535155415535, 0.022170783951878548, 0.024102624505758286, -0.003623821074143052, 0.03230970352888107, 0.01852751523256302, -0.03132433444261551, -0.017218012362718582, 0.011279872618615627, 0.052250444889068604, 0.005604281555861235, 0.010722361505031586, 0.006155309733003378, -0.016362298280000687, 0.0038020950742065907, -0.1179330125451088, 0.0006563718779943883, 0.006923507899045944, 0.010300987400114536, 0.010313952341675758, 0.016128921881318092, 0.010683465749025345, 0.032050397247076035, -0.0040808506309986115, 0.011318768374621868, -0.021016865968704224, -0.05787741392850876, -0.018786821514368057, -0.03155771270394325, 0.010994634591042995, -0.00672254478558898, 0.010605673305690289, -0.029042430222034454, -0.018294138833880424, 0.01147435326129198, -0.0367957204580307, 0.016906842589378357, 0.010385261848568916, -0.006301170215010643, -0.014547145925462246, -0.004356364719569683, -0.03181701898574829, -0.0031505851075053215, 0.004936564713716507, 0.012952405028045177, 0.010398227721452713, -0.018164483830332756, 0.01794407330453396, -0.020977970212697983, -0.0003221084189135581, 0.007617155089974403, 0.0036173383705317974, -0.01026209071278572, 0.037651438266038895, -0.015662167221307755, 0.011156701482832432, -0.014599007554352283, -0.00417160801589489, -0.03412485495209694, 0.010022231377661228, 0.004084091633558273, -0.005659384187310934, -0.0012973473640158772, 0.02266346849501133, -0.015195414423942566, -0.021211346611380577, -0.01056029461324215, -0.008284871466457844, -0.001761669758707285, 0.005711245816200972, 0.009205413050949574, 0.008997967466711998, -0.021470654755830765, -0.02379145473241806, 0.013872946612536907, -0.004845807328820229, -0.016193747520446777, -0.003912300802767277, 0.00304200011305511, -0.002687073079869151, -0.007617155089974403, 0.003983610309660435, -0.028575677424669266, 0.012939440086483955, -0.004434156697243452, -0.020381562411785126, 0.0030338966753333807, -0.022131888195872307, 0.0012187449028715491, -0.020251909270882607, 0.003640027716755867, -0.018449721857905388, 0.008557144552469254, 0.029042430222034454, -0.00807094294577837, -0.025502884760499, -0.025852948427200317, 0.03057234361767769, -0.032205980271101, 0.011779039166867733, 0.007481019012629986, -0.010112988762557507, 0.017114289104938507, 0.011623455211520195, -0.01751621626317501, -0.009341550059616566, -0.005238009616732597, -0.013561777770519257, -0.005001391749829054, -0.014702730812132359, 0.008609006181359291, -0.009568443521857262, 0.00857011042535305, 0.0027049004565924406, 0.009101689793169498, -0.018294138833880424, -0.0010202126577496529, -0.07286538183689117, 0.01214855257421732, -0.011403043754398823, 0.0032656528055667877, 0.0046221548691391945, -0.017568077892065048, 0.019136887043714523, -0.022546779364347458, -0.0037826469633728266, -0.004913875367492437, -0.01572699472308159, 0.034306369721889496, 0.013509916141629219, -0.014158184640109539, -0.011014082469046116, -0.010787188075482845, 0.005027322564274073, 0.002033942611888051, 0.017218012362718582, 0.02478978969156742, -0.010430640541017056, 0.0027437966782599688, 0.00802556425333023, -0.01406742725521326, 0.0038442325312644243, 0.0035038914065808058, -0.003345065750181675, 0.02386924810707569, -0.00384747376665473, -0.012550478801131248, 0.0008500420954078436, -0.012025381438434124, 0.015662167221307755, 0.019914809614419937, 0.029846282675862312, -0.026656802743673325, -0.006203929893672466, -0.011033530347049236, 0.04947585612535477, 0.03575849160552025, -0.007960737682878971, -0.024984268471598625, 0.013548812828958035, -0.02484164945781231, -0.01406742725521326, 0.011681798845529556, -0.022806087508797646, 0.0018378413515165448, 0.030961304903030396, 0.007928323931992054, 0.03251715004444122, 0.010884428396821022, 0.002808623481541872, -0.008466387167572975, 0.02379145473241806, -0.019162818789482117, 0.05357291176915169, -0.0044049848802387714, -0.0040581608191132545, -0.013471020385622978, 0.020718662068247795, 0.00829783733934164, -0.01685498282313347, -0.004100298509001732, -0.000024132808903232217, -0.014482319355010986, -0.03404706344008446, 0.007876462303102016, 0.0011855211341753602, -0.0405556783080101, -0.01225227490067482, -0.006268756929785013, 0.015312102623283863, 0.015299137681722641, 0.013548812828958035, 0.014560110867023468, 0.01471569575369358, -0.002121458761394024, -0.01100111659616232, 0.00015933225222397596, 0.01965550146996975, -0.003769681556150317, -0.02826450765132904, 0.01413225382566452, 0.029198015108704567, 0.048568278551101685, -0.005461662542074919, 0.014274872839450836, 0.0036529931239783764, 0.005160217639058828, 0.0010145402047783136, 0.017243942245841026, -0.006793854292482138, 0.0005344163510017097, 0.01341915875673294, 0.019538814201951027, -0.003721061395481229, -0.01056029461324215, 0.005033805035054684, 0.03562884032726288, -0.004832841921597719, 0.012997783720493317, -0.006443789228796959, -0.015817752107977867, -0.015947405248880386, 0.023208012804389, -0.019590675830841064, -0.0267605260014534, -0.008045012131333351, 0.0018005658639594913, 0.022935740649700165, -0.006323859561234713, -0.0033677550964057446, 0.02027783915400505, -0.020433424040675163, 0.01689387857913971, -0.027019832283258438, -0.040166717022657394, -0.0001858707400970161, 0.009393410757184029, 0.0010169713059440255, 0.00733839999884367, 0.00923782680183649, -0.011007599532604218, 0.022339332848787308, 0.01406742725521326, 0.01659567467868328, -0.021794788539409637, -0.019085025414824486, -0.008245975710451603, 0.016323402523994446, -0.0023759042378515005, -0.0077208783477544785, -0.001962633104994893, 0.0036108556669205427, -0.0008832658641040325, -0.0267605260014534, 0.02873126231133938, -0.022935740649700165, 0.02412855438888073, -0.005513523705303669, 0.00507918419316411, 0.005951105151325464, 0.005173183046281338, 0.005001391749829054, -0.0177625585347414, 0.015130587853491306, -0.01999260112643242, -0.0192406103014946, 0.02140582725405693, -0.007377295754849911, 0.02927580662071705, -0.015104657039046288, -0.01216800045222044, 0.0034552712459117174, -0.003481202060356736, 0.013561777770519257, 0.0022592158056795597, -0.01183090079575777, 0.013665501028299332, 0.017075393348932266, 0.008511765860021114, -0.007409709505736828, -0.0014261907199397683, -0.003058206755667925, 0.0031424816697835922, 0.0021846650633960962, -0.000989419873803854, -0.022144854068756104, 0.0036270625423640013, -0.006233102176338434, -0.016504917293787003, 0.003999816719442606, 0.017931107431650162, -0.025956671684980392, 0.021626237779855728, 0.002192768268287182, -0.001260882243514061, 0.018721995875239372, -0.023493250831961632, 0.030598275363445282, -0.011616972275078297, -0.019331367686390877, 0.01505279541015625, 0.01505279541015625, 0.004524914547801018, 0.0019042887724936008, -0.014962038025259972]
Words that are semantically similar are often represented by vectors that are close to each other in this vector space. This allows for mathematical operations like addition and subtraction to carry semantic meaning. For example, the vector representation of "king" minus "man" plus "woman" should be close to the vector representation of "queen." In other words, vector embeddings are a numerical representation of a particular data object.
A vector index allows you to retrieve a neighborhood of nodes or relationships based on the similarity between the embedding properties of those nodes or relationships and the ones specified in the query.
Create vector indexes
A vector index is a single-label, single-property index for nodes or a single-relationship-type, single-property index for relationships.
It can be used to index nodes or relationships by LIST<INTEGER | FLOAT>
properties valid to the dimensions and vector similarity function of the index.
Note that the available vector index providers (vector-2.0
(default) and vector-1.0
(deprecated)) support different index schemas, property value types, and vector dimensions.
For more information, see Vector index providers for compatibility.
A vector index is created by using the CREATE VECTOR INDEX
command.
It is recommended to give the index a name when it is created.
If no name is given when created, a random name will be assigned.
As of Neo4j 5.16, the index name can also be given as a parameter: CREATE VECTOR INDEX $name …
.
The index name must be unique among both indexes and constraints. A newly created index is not immediately available but is created in the background. |
Creating indexes requires the CREATE INDEX privilege.
|
Movie
nodes on the embedding
property Introduced in 5.15CREATE VECTOR INDEX moviePlots IF NOT EXISTS (1)
FOR (m:Movie)
ON m.embedding
OPTIONS { indexConfig: {
`vector.dimensions`: 1536,
`vector.similarity_function`: 'cosine'
}} (2)
1 | The CREATE VECTOR INDEX command is optionally idempotent.
This means that its default behavior is to throw an error if an attempt is made to create the same index twice.
With IF NOT EXISTS , no error is thrown and nothing happens should an index with the same name, schema or both already exist.
It may still throw an error should a constraint with the same name exist.
As of Neo4j 5.17, an informational notification is returned when nothing happens, showing the existing index which blocks the creation. |
2 | Prior to Neo4j 5.23, the OPTIONS map was mandatory since a vector index could not be created without setting the vector dimensions and similarity function.
Since Neo4j 5.23, both can be omitted.
To read more about the available configuration settings, see Configuration settings.
In this example, the vector dimension is explicitly set to 1536 and the vector similarity function to 'cosine' , which is generally the preferred similarity function for text embeddings.
To read more about the available similarity functions, see Cosine and Euclidean similarity functions. |
Prior to Neo4j 5.15, node vector indexes were created using the db.index.vector.createNodeIndex procedure.
|
You can also create a vector index for relationships with a particular type on a given property using the following syntax:
CREATE VECTOR INDEX name IF NOT EXISTS
FOR ()-[r:REL_TYPE]-() ON (r.embedding)
OPTIONS { indexConfig: {
`vector.dimensions`: $dimension,
`vector.similarity_function`: $similarityFunction
}}
Configuration settings
For more information about the values accepted by different index providers, see Vector index providers for compatibility.
vector.dimensions
The dimensions of the vectors to be indexed.
For more information, see Vectors and embeddings in Neo4j.
This setting can be omitted, and any LIST<INTEGER | FLOAT>
can be indexed and queried, separated by their dimensions, though only vectors of the same dimension can be compared.
Setting this value adds additional checks that ensure only vectors with the configured dimensions are indexed, and querying the index with a vector of a different dimensions returns an error.
It is recommended to provide dimensions when creating a vector index. |
- Accepted values
-
INTEGER
between1
and4096
inclusively. - Default value
-
None. The setting was mandatory prior to Neo4j 5.23.
vector.similarity_function
The name of the similarity function used to assess the similarity of two vectors. To read more about the available similarity functions, see Cosine and Euclidean similarity functions.
- Accepted values
-
STRING
:'cosine'
,'euclidean'
. - Default value
-
'cosine'
. The setting was mandatory prior to Neo4j 5.23.
vector.quantization.enabled
Quantization is a technique to reduce the size of vector representations.
Enabling quantization can accelerate search performance but can slightly decrease accuracy.
It is recommended to enable quantization on machines with limited memory.
Vector indexes created prior to Neo4j 5.23 have this setting effectively set to false
.
- Accepted values
-
BOOLEAN
:true
,false
. - Default value
-
true
Advanced configuration settings
vector.hnsw.m
The M
parameter controls the maximum number of connections each node has in the HNSW (Hierarchical Navigable Small Worlds) graph.
Increasing this value may lead to greater accuracy at the expense of increased index population and update times, especially for vectors with high dimensionality.
Vector indexes created prior to Neo4j 5.23 have this setting effectively set to 16
.
- Accepted values
-
INTEGER
between1
and512
inclusively. - Default value
-
16
vector.hnsw.ef_construction
The number of nearest neighbors tracked during the insertion of vectors into the HNSW graph.
Increasing this value increases the quality of the index, and may lead to greater accuracy (with diminishing returns) at the expense of increased index population and update times.
Vector indexes created prior to Neo4j 5.23 have this setting effectively set to 100
.
- Accepted values
-
INTEGER
between1
and3200
inclusively. - Default value
-
100
Query vector indexes
To query a node vector index, use the db.index.vector.queryNodes
procedure.
An index cannot be used while its state is POPULATING , which occurs immediately after it is created.
To check the state of a vector index — whether it is ONLINE (usable) or POPULATING (still being built; the populationPercent column shows the progress of the index creation) — run the following command: SHOW VECTOR INDEXES .
|
db.index.vector.queryNodes
db.index.vector.queryNodes(indexName :: STRING, numberOfNearestNeighbours :: INTEGER, query :: ANY) :: (node :: NODE, score :: FLOAT)
-
The
indexName
refers to the unique name of the vector index to query. -
The
numberOfNearestNeighbours
refers to the number of nearest neighbors to return. -
The
query
vector refers to theLIST<INTEGER | FLOAT>
in which to search for the neighborhood.
The procedure returns the neighborhood of nodes with their respective similarity scores, ordered by those scores.
The scores are bounded between 0
and 1
, where the closer to 1
the score is, the more similar the indexed vector is to the query vector.
MATCH (m:Movie {title: 'Godfather, The'})
CALL db.index.vector.queryNodes('moviePlots', 5, m.embedding)
YIELD node AS movie, score
RETURN movie.title AS title, movie.plot AS plot, score
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| title | plot | score |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "Godfather, The" | "The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son." | 1.0 |
| "Godfather: Part III, The" | "In the midst of trying to legitimize his business dealings in New York and Italy in 1979, aging Mafia don Michael Corleone seeks to avow for his sins while taking a young protégé under his wing." | 0.9648237228393555 |
| "Godfather: Part II, The" | "The early life and career of Vito Corleone in 1920s New York is portrayed while his son, Michael, expands and tightens his grip on his crime syndicate stretching from Lake Tahoe, Nevada to pre-revolution 1958 Cuba." | 0.9547788500785828 |
| "Goodfellas" | "Henry Hill and his friends work their way up through the mob hierarchy." | 0.9300689697265625 |
| "Scarface" | "An ambitious and near insanely violent gangster climbs the ladder of success in the mob, but his weaknesses prove to be his downfall." | 0.9367183446884155 |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Note that all movies returned have a plot centred around criminal family organizations.
The score
results are returned in descending order, where the best matching result entry is put first (in this case, The Godfather
has a similarity score of 1.0
, which is to be expected as the index was queried with this specific property).
If the query vector itself is not wanted, adding the predicate WHERE score < 1
removes identical vectors.
To query a relationship vector index, use the db.index.vector.queryRelationships
procedure.
db.index.vector.queryRelationships
Introduced in 5.18db.index.vector.queryRelationships(indexName :: STRING, numberOfNearestNeighbours :: INTEGER, query :: ANY) :: (relationship :: RELATIONSHIP, score :: FLOAT)
db.index.vector.queryRelationships
has the same argument descriptions as db.index.vector.queryNodes
.
Use Vector functions to compute the similarity score between two specific vector pairs without using a vector index. |
Performance suggestions
Vector indexes can take advantage of the incubated Java 20 Vector API for noticeable speed improvements. If you are using a compatible version of Java, you can add the following setting to your configuration settings:
server.jvm.additional=--add-modules=jdk.incubator.vector
Show vector indexes
To list all vector indexes in a database, use the SHOW VECTOR INDEXES
command.
This is the same SHOW
command as for other indexes, with the index type filtering on VECTOR
.
Listing indexes requires the SHOW INDEX privilege.
|
SHOW VECTOR INDEXES
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | name | state | populationPercent | type | entityType | labelsOrTypes | properties | indexProvider | owningConstraint | lastRead | readCount |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 2 | "moviePlots" | "ONLINE" | 100.0 | "VECTOR" | "NODE" | ["Movie"] | ["embedding"] | "vector-2.0" | NULL | 2024-05-07T09:19:09.225Z | 47 |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
For a full description of all return columns, see Search-performance indexes → Result columns for listing indexes.
To return full vector index details, use YIELD *
.
SHOW VECTOR INDEXES YIELD *
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | name | state | populationPercent | type | entityType | labelsOrTypes | properties | indexProvider | owningConstraint| lastRead | readCount | trackedSince | options | failureMessage | createStatement |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 2 | "moviePlots"| "ONLINE" | 100.0 | "VECTOR" | "NODE" | ["Movie"] | ["embedding"] | "vector-2.0" | NULL | 2024-05-07T09:19:09.225Z | 47 | 2024-05-07T08:26:19.072Z | {indexConfig: {`vector.dimensions`: 1536, `vector.hnsw.m`: 16, `vector.quantization.enabled`: TRUE, `vector.similarity_function`: "COSINE", `vector.hnsw.ef_construction`: 100}, indexProvider: "vector-2.0"} | "" | "CREATE VECTOR INDEX `moviePlots` FOR (n:`Movie`) ON (n.`embedding`) OPTIONS {indexConfig: {`vector.dimensions`: 1536,`vector.hnsw.ef_construction`: 100,`vector.hnsw.m`: 16,`vector.quantization.enabled`: true,`vector.similarity_function`: 'COSINE'}}" |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
To return only specific details, specify the desired column name(s) after the YIELD
clause.
SHOW VECTOR INDEXES YIELD name, type, entityType, labelsOrTypes, properties
+----------------------------------------------------------------------+
| name | type | entityType | labelsOrTypes | properties |
+----------------------------------------------------------------------+
| "moviePlots" | "VECTOR" | "NODE" | ["Movie"] | ["embedding"] |
+----------------------------------------------------------------------+
Drop vector indexes
A vector index is dropped by using the same command as for other indexes, DROP INDEX
.
As of Neo4j 5.16, the index name can also be given as a parameter when dropping an index: DROP INDEX $name
.
Dropping indexes requires the DROP INDEX privilege.
|
DROP INDEX moviePlots
Vector index providers for compatibility
As of Neo4j 5.18, the default index provider is vector-2.0
.
As of Neo4j 5.26, it is no longer possible to specify an index provider when creating indexes.
Instead, Neo4j selects the most performant provider (currently vector-2.0
).
Previously created vector-1.0
indexes will continue to function.
Learn more about vector index provider differences
Supported | vector-1.0 |
vector-2.0 |
---|---|---|
Index schema |
Single-label, single-property index for nodes.
No relationship support. |
Single-label, single-property index for nodes.
Single-type, single-property index for relationships. |
Indexed property value type |
|
|
Indexed vector dimension |
|
|
All vector components can be represented finitely in IEEE 754 single precision.
Its -norm is non-zero and can be represented finitely in IEEE 754 single precision. |
All vector components can be represented finitely in IEEE 754 double precision.
Its -norm is non-zero and can be represented finitely in IEEE 754 double precision.
The ratio of each vector component with its -norm can be represented finitely in IEEE 754 single precision. |
Cosine and Euclidean similarity functions
The choice of similarity function affects which indexed vectors are considered similar, and which are valid. The semantic meaning of the vector may itself dictate which similarity function to choose. Refer to the documentation for the particular vector embedding model you are using, as it may suggest a preference for certain similarity functions. Otherwise, being able to differentiate between the various similarity functions can assist in making a more informed decision.
Name | Case insensitive argument | Key similarity feature |
---|---|---|
Cosine |
|
angle |
Euclidean |
|
distance |
For -normalized vectors (unit vectors), cosine and Euclidean similarity functions produce the same similarity ordering.
Learn more about the cosine similarity function
Cosine similarity is used when the angle between the vectors is what determines how similar two vectors are.
A valid vector for a cosine vector index is when:
-
All vector components can be represented finitely in IEEE 754 double precision.[2]
-
Its -norm is non-zero and can be represented finitely in IEEE 754 double precision.
-
The ratio of each vector component with its -norm can be represented finitely in IEEE 754 single precision.
Cosine similarity interprets the vectors in Cartesian coordinates. The measure is related to the angle between the two vectors. However, an angle can be described in many units, sign conventions, and periods. The trigonometric cosine of this angle is both agnostic to the aforementioned angle conventions and bounded. Cosine similarity rebounds the trigonometric cosine.
In the above equation the trigonometric cosine is given by the scalar product of the two unit vectors.
Learn more about the Euclidean similarity function
Euclidean similarity is useful when the distance between the vectors is what determines how similar two vectors are.
A valid vector for a Euclidean vector index is when all vector components can be represented finitely in IEEE 754 single precision.
Euclidean interprets the vectors in Cartesian coordinates. The measure is related to the Euclidean distance, i.e., how far two points are from one another. However, that distance is unbounded and less useful as a similarity score. Euclidean similarity bounds the square of the Euclidean distance.
Vector index procedures
Usage | Procedure | Description |
---|---|---|
Create node vector index. |
Create a vector index for the specified label and property with the given vector dimension using the given similarity function.
Replaced by the |
|
Use node vector index. |
Query the given node vector index. Returns the requested number of approximate nearest neighbor nodes and their similarity score, ordered by score. |
|
Use relationship vector index. |
Query the given relationship vector index. Returns the requested number of approximate nearest neighbor relationships and their similarity score, ordered by score. Introduced in 5.18 |
|
Set node vector property. |
Update a given node property with the given vector in a more space-efficient way than directly using |
|
Set node vector property. |
Replaced by |
|
Set relationship vector property. |
Update a given relationship property with the given vector in a more space-efficient way than directly using |
Limitations and known issues
As of Neo4j 5.13, the vector index is no longer a beta feature. It does, however, still contain some limitations and known issues.
Limitations
-
The query is an approximate nearest neighbor search. The requested k nearest neighbors may not be the exact k nearest, but close within the same wider neighborhood.
-
For large requested nearest neighbors, k, close to the total number of indexed vectors, the search may retrieve fewer than k results.
-
Only one vector index can be over a schema. For example, you cannot have one Euclidean and one cosine vector index on the same label-property key pair.
-
Changes made within the same transaction are not visible to the index.
Known issues
The following table lists the known issues and, if fixed, the version in which they were fixed:
Known issues | Fixed in | ||
---|---|---|---|
The creation of a vector index using the legacy procedure
|
|||
Procedure signatures from
|
|||
No provided settings or options for tuning the index. |
Neo4j 5.23 |
||
Only node vector indexes are supported. |
Neo4j 5.18 |
||
Vector indexes cannot be assigned autogenerated names. |
Neo4j 5.15 |
||
There is no Cypher syntax for creating a vector index.
|
Neo4j 5.15 |
||
The standard index type filtering for
|
Neo4j 5.15 |
||
Vector indexes may incorrectly reject valid queries in a cluster setting. This is caused by an issue in the handling of index capabilities on followers.
|
Neo4j 5.14 |
||
Querying for a single approximate nearest neighbor from an index would fail a validation check. Passing a |
Neo4j 5.13 |
||
Vector index queries throw an exception if the transaction state contains changes. This means that writes may only take place after the last vector index query in a transaction.
|
Neo4j 5.13 |
||
|
Neo4j 5.12 |
||
Passing |
Neo4j 5.12 |
||
The creation of the vector index skipped the check to limit the dimension to
|
Neo4j 5.12 |
||
The validation for cosine similarity verifies that the vector’s -norm can be represented finitely in IEEE 754 double precision, rather than in single precision.
This can lead to certain large component vectors being incorrectly indexed, and return a similarity score of |
Neo4j 5.12 |
||
|
Neo4j 5.12 |
||
The vector index |
Neo4j 5.12 |
||
Copying a database store with a vector index does not log the recreation command, and instead logs an error: ERROR: [StoreCopy] Unable to format statement for index 'index-name' Due to an: java.lang.IllegalArgumentException: Did not recognize index type VECTOR
|
Neo4j 5.12 |
||
Some of the protections preventing the use of new features during a database rolling upgrade are missing. This can result in a transaction to create a vector index on a cluster member running Neo4j 5.11 and distributing it to other cluster members running an older Neo4j version. The older Neo4j versions will fail to understand the transaction.
|
Neo4j 5.12 |