Skip to content

Commit 3cca0bf

Browse files
committed
Rename to search
1 parent 2fcfdb1 commit 3cca0bf

File tree

10 files changed

+104
-104
lines changed

10 files changed

+104
-104
lines changed

idl/chromadb/proto/query_executor.proto

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,26 @@ message ProjectOperator {
154154
repeated string fields = 1;
155155
}
156156

157-
message RetrievePayload {
157+
message SearchPayload {
158158
FilterOperator filter = 1;
159159
ScoreOperator score = 2;
160160
LimitOperator limit = 3;
161161
ProjectOperator project = 4;
162162
}
163163

164-
message RetrievePlan {
164+
message SearchPlan {
165165
ScanOperator scan = 1;
166-
repeated RetrievePayload payloads = 2;
166+
repeated SearchPayload payloads = 2;
167167
}
168168

169-
message RetrieveResult {
169+
message SearchResult {
170170
repeated string results = 1;
171171
}
172172

173173
service QueryExecutor {
174174
rpc Count(CountPlan) returns (CountResult) {}
175175
rpc Get(GetPlan) returns (GetResult) {}
176176
rpc KNN(KNNPlan) returns (KNNBatchResult) {}
177-
rpc Retrieve(RetrievePlan) returns (RetrieveResult) {}
177+
rpc Search(SearchPlan) returns (SearchResult) {}
178178
}
179179

rust/frontend/src/executor/distributed.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use chroma_system::System;
1515
use chroma_types::chroma_proto::query_executor_client::QueryExecutorClient;
1616
use chroma_types::SegmentType;
1717
use chroma_types::{
18-
operator::{CountResult, GetResult, KnnBatchResult, RetrieveResult},
19-
plan::{Count, Get, Knn, Retrieve},
18+
operator::{CountResult, GetResult, KnnBatchResult, SearchResult},
19+
plan::{Count, Get, Knn, Search},
2020
ExecutorError,
2121
};
2222

@@ -210,7 +210,7 @@ impl DistributedExecutor {
210210
Ok(res.into_inner().try_into()?)
211211
}
212212

213-
pub async fn retrieve(&mut self, plan: Retrieve) -> Result<RetrieveResult, ExecutorError> {
213+
pub async fn search(&mut self, plan: Search) -> Result<SearchResult, ExecutorError> {
214214
// Get the collection ID from the plan
215215
let collection_id = &plan
216216
.scan
@@ -225,7 +225,7 @@ impl DistributedExecutor {
225225
.map_err(|e| ExecutorError::Internal(e.boxed()))?;
226226

227227
// Convert plan to proto
228-
let request: chroma_types::chroma_proto::RetrievePlan = plan.try_into()?;
228+
let request: chroma_types::chroma_proto::SearchPlan = plan.try_into()?;
229229

230230
let attempt_count = std::sync::Arc::new(std::sync::atomic::AtomicU32::new(0));
231231
let config = self.client_selection_config.clone();
@@ -236,7 +236,7 @@ impl DistributedExecutor {
236236
attempt_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
237237
let is_retry = current_attempt > 0;
238238
choose_query_client_weighted(&clients, &config, is_retry)?
239-
.retrieve(Request::new(request.clone()))
239+
.search(Request::new(request.clone()))
240240
.await
241241
})
242242
.retry(self.backoff)

rust/frontend/src/executor/local.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use chroma_system::ComponentHandle;
1212
use chroma_types::{
1313
operator::{
1414
CountResult, Filter, GetResult, KnnBatchResult, KnnProjectionOutput, KnnProjectionRecord,
15-
Projection, ProjectionRecord, RecordDistance, RetrieveResult,
15+
Projection, ProjectionRecord, RecordDistance, SearchResult,
1616
},
17-
plan::{Count, Get, Knn, Retrieve},
17+
plan::{Count, Get, Knn, Search},
1818
CollectionAndSegments, CollectionUuid, ExecutorError, HnswSpace, SegmentType,
1919
};
2020
use std::{
@@ -306,9 +306,9 @@ impl LocalExecutor {
306306
})
307307
}
308308

309-
pub async fn retrieve(&mut self, _plan: Retrieve) -> Result<RetrieveResult, ExecutorError> {
309+
pub async fn search(&mut self, _plan: Search) -> Result<SearchResult, ExecutorError> {
310310
Err(ExecutorError::NotImplemented(
311-
"Retrieve operation is not implemented for local executor".to_string(),
311+
"Search operation is not implemented for local executor".to_string(),
312312
))
313313
}
314314

rust/frontend/src/executor/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use chroma_types::{
2-
operator::{CountResult, GetResult, KnnBatchResult, RetrieveResult},
3-
plan::{Count, Get, Knn, Retrieve},
2+
operator::{CountResult, GetResult, KnnBatchResult, SearchResult},
3+
plan::{Count, Get, Knn, Search},
44
ExecutorError, SegmentType,
55
};
66
use distributed::DistributedExecutor;
@@ -38,12 +38,12 @@ impl Executor {
3838
Executor::Local(local_executor) => local_executor.knn(plan).await,
3939
}
4040
}
41-
pub async fn retrieve(&mut self, plan: Retrieve) -> Result<RetrieveResult, ExecutorError> {
41+
pub async fn search(&mut self, plan: Search) -> Result<SearchResult, ExecutorError> {
4242
match self {
4343
Executor::Distributed(distributed_executor) => {
44-
distributed_executor.retrieve(plan).await
44+
distributed_executor.search(plan).await
4545
}
46-
Executor::Local(local_executor) => local_executor.retrieve(plan).await,
46+
Executor::Local(local_executor) => local_executor.search(plan).await,
4747
}
4848
}
4949
pub async fn is_ready(&self) -> bool {

rust/frontend/src/impls/service_based_frontend.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use chroma_sysdb::{GetCollectionsOptions, SysDb};
1818
use chroma_system::System;
1919
use chroma_types::{
2020
operator::{Filter, KnnBatch, KnnProjection, Limit, Projection, Scan},
21-
plan::{Count, Get, Knn, Retrieve},
21+
plan::{Count, Get, Knn, Search},
2222
AddCollectionRecordsError, AddCollectionRecordsRequest, AddCollectionRecordsResponse,
2323
Collection, CollectionUuid, CountCollectionsError, CountCollectionsRequest,
2424
CountCollectionsResponse, CountRequest, CountResponse, CreateCollectionError,
@@ -34,7 +34,7 @@ use chroma_types::{
3434
HeartbeatError, HeartbeatResponse, Include, KnnIndex, ListCollectionsRequest,
3535
ListCollectionsResponse, ListDatabasesError, ListDatabasesRequest, ListDatabasesResponse,
3636
Operation, OperationRecord, QueryError, QueryRequest, QueryResponse, ResetError, ResetResponse,
37-
RetrieveRequest, RetrieveResponse, Segment, SegmentScope, SegmentType, SegmentUuid,
37+
SearchRequest, SearchResponse, Segment, SegmentScope, SegmentType, SegmentUuid,
3838
UpdateCollectionError, UpdateCollectionRecordsError, UpdateCollectionRecordsRequest,
3939
UpdateCollectionRecordsResponse, UpdateCollectionRequest, UpdateCollectionResponse,
4040
UpdateTenantError, UpdateTenantRequest, UpdateTenantResponse, UpsertCollectionRecordsError,
@@ -63,7 +63,7 @@ struct Metrics {
6363
add_retries_counter: Counter<u64>,
6464
update_retries_counter: Counter<u64>,
6565
upsert_retries_counter: Counter<u64>,
66-
retrieve_retries_counter: Counter<u64>,
66+
search_retries_counter: Counter<u64>,
6767
}
6868

6969
#[derive(Clone, Debug)]
@@ -103,7 +103,7 @@ impl ServiceBasedFrontend {
103103
let add_retries_counter = meter.u64_counter("add_retries").build();
104104
let update_retries_counter = meter.u64_counter("update_retries").build();
105105
let upsert_retries_counter = meter.u64_counter("upsert_retries").build();
106-
let retrieve_retries_counter = meter.u64_counter("retrieve_retries").build();
106+
let search_retries_counter = meter.u64_counter("search_retries").build();
107107
let metrics = Arc::new(Metrics {
108108
fork_retries_counter,
109109
delete_retries_counter,
@@ -113,7 +113,7 @@ impl ServiceBasedFrontend {
113113
add_retries_counter,
114114
update_retries_counter,
115115
upsert_retries_counter,
116-
retrieve_retries_counter,
116+
search_retries_counter,
117117
});
118118
// factor: 2.0,
119119
// min_delay_ms: 100,
@@ -1581,47 +1581,47 @@ impl ServiceBasedFrontend {
15811581
res
15821582
}
15831583

1584-
pub async fn retryable_retrieve(
1584+
pub async fn retryable_search(
15851585
&mut self,
1586-
request: RetrieveRequest,
1587-
) -> Result<RetrieveResponse, QueryError> {
1586+
request: SearchRequest,
1587+
) -> Result<SearchResponse, QueryError> {
15881588
// Get collection and segments once for all queries
15891589
let collection_and_segments = self
15901590
.collections_with_segments_provider
15911591
.get_collection_with_segments(request.collection_id)
15921592
.await
15931593
.map_err(|err| QueryError::Other(Box::new(err) as Box<dyn ChromaError>))?;
15941594

1595-
// Create a single Retrieve plan with one scan and the payloads from the request
1596-
let retrieve_plan = Retrieve {
1595+
// Create a single Search plan with one scan and the payloads from the request
1596+
let search_plan = Search {
15971597
scan: Scan {
15981598
collection_and_segments,
15991599
},
1600-
payloads: request.retrievals,
1600+
payloads: request.searches,
16011601
};
16021602

1603-
// Execute the single retrieve plan using the executor
1604-
let result = self.executor.retrieve(retrieve_plan).await?;
1603+
// Execute the single search plan using the executor
1604+
let result = self.executor.search(search_plan).await?;
16051605

1606-
Ok(RetrieveResponse {
1606+
Ok(SearchResponse {
16071607
results: result.results,
16081608
})
16091609
}
16101610

1611-
pub async fn retrieve(
1611+
pub async fn search(
16121612
&mut self,
1613-
request: RetrieveRequest,
1614-
) -> Result<RetrieveResponse, QueryError> {
1613+
request: SearchRequest,
1614+
) -> Result<SearchResponse, QueryError> {
16151615
let retries = Arc::new(AtomicUsize::new(0));
1616-
let retrieve_to_retry = || {
1616+
let search_to_retry = || {
16171617
let mut self_clone = self.clone();
16181618
let request_clone = request.clone();
16191619
let cache_clone = self
16201620
.collections_with_segments_provider
16211621
.collections_with_segments_cache
16221622
.clone();
16231623
async move {
1624-
let res = self_clone.retryable_retrieve(request_clone).await;
1624+
let res = self_clone.retryable_search(request_clone).await;
16251625
match res {
16261626
Ok(res) => Ok(res),
16271627
Err(e) => {
@@ -1637,22 +1637,22 @@ impl ServiceBasedFrontend {
16371637
}
16381638
}
16391639
};
1640-
let res = retrieve_to_retry
1640+
let res = search_to_retry
16411641
.retry(self.collections_with_segments_provider.get_retry_backoff())
16421642
// NOTE: Transport level errors will manifest as unknown errors, and they should also be retried
16431643
.when(|e| matches!(e.code(), ErrorCodes::NotFound | ErrorCodes::Unknown))
16441644
.notify(|_, _| {
16451645
let retried = retries.fetch_add(1, Ordering::Relaxed);
16461646
if retried > 0 {
16471647
tracing::info!(
1648-
"Retrying retrieve() request for collection {}",
1648+
"Retrying search() request for collection {}",
16491649
request.collection_id
16501650
);
16511651
}
16521652
})
16531653
.await;
16541654
self.metrics
1655-
.retrieve_retries_counter
1655+
.search_retries_counter
16561656
.add(retries.load(Ordering::Relaxed) as u64, &[]);
16571657
res
16581658
}

rust/frontend/src/server.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use chroma_metering::{
1010
ExternalCollectionReadContext, MeteredFutureExt, ReadAction, StartRequest, WriteAction,
1111
};
1212
use chroma_system::System;
13-
use chroma_types::plan::RetrievePayload;
13+
use chroma_types::plan::SearchPayload;
1414
use 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

131131
impl 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

Comments
 (0)