@@ -72,6 +72,41 @@ void main() {
7272 expect (closest2.name, "node8" );
7373 });
7474
75+ test ('vectorSearchCitiesGeo' , () {
76+ // capital cities across Europe
77+ List <String > cities = ["Berlin" , "Paris" , "Rome" , "Madrid" , "London" ];
78+ List <List <double >> coordinates = [
79+ [52.5200 , 13.4050 ],
80+ [48.8566 , 2.3522 ],
81+ [41.9028 , 12.4964 ],
82+ [40.4168 , - 3.7038 ],
83+ [51.5074 , - 0.1278 ]
84+ ];
85+
86+ box.putMany (List .generate (cities.length, (i) {
87+ return HnswObject ()
88+ ..name = cities[i]
89+ ..floatVectorGeoCoordinates = coordinates[i];
90+ }));
91+
92+ // lat/lng for Munich
93+ final List <double > searchVector = [48.1371 , 11.5754 ];
94+
95+ final query = box
96+ .query (HnswObject_ .floatVectorGeoCoordinates
97+ .nearestNeighborsF32 (searchVector, 5 ))
98+ .build ();
99+ addTearDown (() => query.close ());
100+
101+ final nearestCities = query.find ();
102+ expect (nearestCities.length, 5 );
103+ expect (nearestCities[0 ].name, "Berlin" );
104+ expect (nearestCities[1 ].name, "Paris" );
105+ expect (nearestCities[2 ].name, "Rome" );
106+ expect (nearestCities[3 ].name, "Madrid" );
107+ expect (nearestCities[4 ].name, "London" );
108+ });
109+
75110 test ('find offset limit' , () {
76111 box.putMany (List .generate (15 , (index) {
77112 final i = index + 1 ; // start at 1
0 commit comments