@@ -10,7 +10,7 @@ use chroma_metering::{
1010 ExternalCollectionReadContext , MeteredFutureExt , ReadAction , StartRequest , WriteAction ,
1111} ;
1212use chroma_system:: System ;
13- use chroma_types:: plan:: RetrievePayload ;
13+ use chroma_types:: plan:: SearchPayload ;
1414use chroma_types:: {
1515 AddCollectionRecordsResponse , ChecklistResponse , Collection , CollectionConfiguration ,
1616 CollectionMetadataUpdate , CollectionUuid , CountCollectionsRequest , CountCollectionsResponse ,
@@ -22,7 +22,7 @@ use chroma_types::{
2222 HeartbeatResponse , IncludeList , InternalCollectionConfiguration ,
2323 InternalUpdateCollectionConfiguration , ListCollectionsRequest , ListCollectionsResponse ,
2424 ListDatabasesRequest , ListDatabasesResponse , Metadata , QueryRequest , QueryResponse ,
25- RetrieveRequest , RetrieveResponse , UpdateCollectionConfiguration ,
25+ SearchRequest , SearchResponse , UpdateCollectionConfiguration ,
2626 UpdateCollectionRecordsResponse , UpdateCollectionResponse , UpdateMetadata , UpdateTenantRequest ,
2727 UpdateTenantResponse , UpsertCollectionRecordsResponse ,
2828} ;
@@ -125,7 +125,7 @@ pub struct Metrics {
125125 collection_count : Counter < u64 > ,
126126 collection_get : Counter < u64 > ,
127127 collection_query : Counter < u64 > ,
128- collection_retrieve : Counter < u64 > ,
128+ collection_search : Counter < u64 > ,
129129}
130130
131131impl Metrics {
@@ -159,7 +159,7 @@ impl Metrics {
159159 collection_count : meter. u64_counter ( "collection_count" ) . build ( ) ,
160160 collection_get : meter. u64_counter ( "collection_get" ) . build ( ) ,
161161 collection_query : meter. u64_counter ( "collection_query" ) . build ( ) ,
162- collection_retrieve : meter. u64_counter ( "collection_retrieve " ) . build ( ) ,
162+ collection_search : meter. u64_counter ( "collection_search " ) . build ( ) ,
163163 }
164164 }
165165}
@@ -299,7 +299,7 @@ impl FrontendServer {
299299 )
300300 . route (
301301 "/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/retrieve" ,
302- post ( collection_retrieve ) ,
302+ post ( collection_search ) ,
303303 )
304304 . merge ( docs_router)
305305 . with_state ( self )
@@ -2175,41 +2175,41 @@ async fn collection_query(
21752175}
21762176
21772177#[ derive( Debug , Clone , Deserialize , ToSchema ) ]
2178- pub struct RetrieveRequestPayload {
2179- retrievals : Vec < RetrievePayload > ,
2178+ pub struct SearchRequestPayload {
2179+ searches : Vec < SearchPayload > ,
21802180}
21812181
2182- /// Retrieve records from a collection with hybrid criterias.
2182+ /// Search records from a collection with hybrid criterias.
21832183#[ utoipa:: path(
21842184 post,
2185- path = "/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/retrieve " ,
2186- request_body = RetrieveRequestPayload ,
2185+ path = "/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/search " ,
2186+ request_body = SearchRequestPayload ,
21872187 responses(
2188- ( status = 200 , description = "Records retrieved from the collection" , body = RetrieveResponse ) ,
2188+ ( status = 200 , description = "Records searched from the collection" , body = SearchResponse ) ,
21892189 ( status = 401 , description = "Unauthorized" , body = ErrorResponse ) ,
21902190 ( status = 404 , description = "Collection not found" , body = ErrorResponse ) ,
21912191 ( status = 500 , description = "Server error" , body = ErrorResponse )
21922192 ) ,
21932193 params(
21942194 ( "tenant" = String , Path , description = "Tenant ID" ) ,
21952195 ( "database" = String , Path , description = "Database name for the collection" ) ,
2196- ( "collection_id" = String , Path , description = "Collection ID to retrieve records from" )
2196+ ( "collection_id" = String , Path , description = "Collection ID to search records from" )
21972197 )
21982198) ]
2199- async fn collection_retrieve (
2199+ async fn collection_search (
22002200 headers : HeaderMap ,
22012201 Path ( ( tenant, database, collection_id) ) : Path < ( String , String , String ) > ,
22022202 State ( mut server) : State < FrontendServer > ,
2203- TracedJson ( payload) : TracedJson < RetrieveRequestPayload > ,
2204- ) -> Result < Json < RetrieveResponse > , ServerError > {
2205- server. metrics . collection_retrieve . add (
2203+ TracedJson ( payload) : TracedJson < SearchRequestPayload > ,
2204+ ) -> Result < Json < SearchResponse > , ServerError > {
2205+ server. metrics . collection_search . add (
22062206 1 ,
22072207 & [
22082208 KeyValue :: new ( "tenant" , tenant. clone ( ) ) ,
22092209 KeyValue :: new ( "collection_id" , collection_id. clone ( ) ) ,
22102210 ] ,
22112211 ) ;
2212- // TODO: Maybe add AuthzAction:Retrieve
2212+ // TODO: Maybe add AuthzAction:Search
22132213 let requester_identity = server
22142214 . authenticate_and_authorize_collection (
22152215 & headers,
@@ -2230,15 +2230,15 @@ async fn collection_retrieve(
22302230 . map ( |val| val. to_str ( ) . unwrap_or_default ( ) )
22312231 . map ( |val| val. to_string ( ) ) ;
22322232
2233- // TODO: Add quota enforcement for retrieve
2233+ // TODO: Add quota enforcement for search
22342234 let _guard = server. scorecard_request ( & [
22352235 "op:read" ,
22362236 format ! ( "tenant:{}" , tenant) . as_str ( ) ,
22372237 format ! ( "collection:{}" , collection_id) . as_str ( ) ,
22382238 format ! ( "requester:{}" , requester_identity. tenant) . as_str ( ) ,
22392239 ] ) ?;
22402240
2241- // TODO: Maybe add ReadAction::Retrieve
2241+ // TODO: Maybe add ReadAction::Search
22422242 // Create a metering context
22432243 let metering_context_container = if requester_identity. tenant == tenant {
22442244 chroma_metering:: create :: < CollectionReadContext > ( CollectionReadContext :: new (
@@ -2265,14 +2265,14 @@ async fn collection_retrieve(
22652265 } ) ;
22662266
22672267 tracing:: info!(
2268- name: "collection_retrieve " ,
2269- num_queries = payload. retrievals . len( ) ,
2268+ name: "collection_search " ,
2269+ num_queries = payload. searches . len( ) ,
22702270 ) ;
22712271
2272- let request = RetrieveRequest :: try_new ( tenant, database, collection_id, payload. retrievals ) ?;
2272+ let request = SearchRequest :: try_new ( tenant, database, collection_id, payload. searches ) ?;
22732273 let res = server
22742274 . frontend
2275- . retrieve ( request)
2275+ . search ( request)
22762276 . meter ( metering_context_container)
22772277 . await ?;
22782278 Ok ( Json ( res) )
@@ -2335,7 +2335,7 @@ impl Modify for ChromaTokenSecurityAddon {
23352335 collection_count,
23362336 collection_get,
23372337 collection_query,
2338- collection_retrieve ,
2338+ collection_search ,
23392339 ) ,
23402340 // Apply our new security scheme here
23412341 modifiers( & ChromaTokenSecurityAddon )
0 commit comments