@@ -703,19 +703,17 @@ def test_15_encrypted_index_query(self):
703703 query_vector = self .test_vectors [0 ]
704704
705705 # Test query with default include (should be ["distance", "metadata"])
706+ # Single query now returns results directly (not wrapped in a list)
706707 results = self .index .query (query_vectors = [query_vector ])
707708
708709 self .assertIsInstance (results , list )
709- self .assertEqual (len (results ), 1 , "Should have 1 result for 1 query" )
710-
711- query_results = results [0 ]
712- self .assertIsInstance (query_results , list )
710+ # Single query returns flat list of results
713711 self .assertGreater (
714- len (query_results ), 0 , "Query should return at least one result"
712+ len (results ), 0 , "Query should return at least one result"
715713 )
716714
717715 # Check exact structure with default include - id is always included, plus distance and metadata by default
718- for result in query_results :
716+ for result in results :
719717 self .assertIsInstance (result , dict )
720718 validate_exact_keys (
721719 result ,
@@ -755,7 +753,7 @@ def test_15_encrypted_index_query(self):
755753 query_vectors = [query_vector ], top_k = 5 , include = ["metadata" ]
756754 )
757755
758- for result in results [ 0 ] :
756+ for result in results :
759757 validate_exact_keys (
760758 result ,
761759 {"id" , "distance" , "metadata" },
@@ -775,7 +773,7 @@ def test_15_encrypted_index_query(self):
775773 # Test with empty include (should only have id and distance)
776774 results = self .index .query (query_vectors = [query_vector ], include = ["distance" ])
777775
778- for result in results [ 0 ] :
776+ for result in results :
779777 validate_exact_keys (
780778 result , {"id" , "distance" }, "query() result with include=[]"
781779 )
@@ -786,7 +784,7 @@ def test_15_encrypted_index_query(self):
786784 )
787785
788786 # Results should have id, distance, and metadata (default include)
789- for result in results [ 0 ] :
787+ for result in results :
790788 validate_exact_keys (
791789 result ,
792790 {"id" , "distance" , "metadata" },
@@ -817,20 +815,17 @@ def test_16_encrypted_index_query_patterns(self):
817815 self .assertIn ("id" , results [0 ])
818816 self .assertIn ("distance" , results [0 ])
819817
820- # Test Pattern 2: Single vector in nested list -> nested list return
818+ # Test Pattern 2: Single vector in nested list -> flat list return (API update)
821819 single_vector_nested = [self .test_vectors [1 ].tolist ()]
822820 results = self .index .query (query_vectors = single_vector_nested , top_k = 3 )
823821
824- # Should return list of lists (batch format)
822+ # Single query now returns flat list of results directly
825823 self .assertIsInstance (results , list )
826- self .assertEqual (len (results ), 1 , "Should have 1 result list for 1 query" )
827- self .assertIsInstance (
828- results [0 ], list , "Batch query should return nested lists"
829- )
830- if len (results [0 ]) > 0 :
831- self .assertIsInstance (results [0 ][0 ], dict , "Each result should be a dict" )
832- self .assertIn ("id" , results [0 ][0 ])
833- self .assertIn ("distance" , results [0 ][0 ])
824+ self .assertGreater (len (results ), 0 , "Should have results for single query" )
825+ if len (results ) > 0 :
826+ self .assertIsInstance (results [0 ], dict , "Single query should return flat list of dicts" )
827+ self .assertIn ("id" , results [0 ])
828+ self .assertIn ("distance" , results [0 ])
834829
835830 # Test Pattern 3: Multiple vectors -> multiple result lists
836831 multiple_vectors = [
@@ -903,7 +898,7 @@ def test_16_encrypted_index_query_patterns(self):
903898 )
904899
905900 # Test Pattern 6: Text-based query with query_contents
906- # Single text query
901+ # Single text query (returns flat list directly)
907902 text_query = "test content for similarity search"
908903 results = self .index .query (query_contents = text_query , top_k = 3 )
909904
0 commit comments