@@ -22,7 +22,10 @@ use common::{
2222 WriteTimestamp ,
2323 } ,
2424} ;
25- use errors:: ErrorMetadata ;
25+ use errors:: {
26+ ErrorMetadata ,
27+ ErrorMetadataAnyhowExt ,
28+ } ;
2629use futures:: {
2730 future:: BoxFuture ,
2831 FutureExt ,
@@ -400,46 +403,59 @@ impl VectorIndexManager {
400403 search_storage : Arc < dyn Storage > ,
401404 ) -> anyhow:: Result < Vec < VectorSearchQueryResult > > {
402405 let timer = metrics:: search_timer ( & SEARCHLIGHT_CLUSTER_NAME ) ;
403- let IndexConfig :: Vector {
404- ref developer_config,
405- ..
406- } = index. metadata . config
407- else {
408- anyhow:: bail!( ErrorMetadata :: bad_request(
409- "IndexNotAVectorIndexError" ,
410- format!(
411- "Index {} is not a vector index" ,
412- query. printable_index_name( ) ?
413- )
414- ) ) ;
415- } ;
416- let Some ( ( vector_index, memory_index) ) = self . require_ready_index ( & index. id ( ) ) ? else {
417- anyhow:: bail!( "Vector index {:?} not available" , index. id( ) ) ;
418- } ;
419- let qdrant_schema = QdrantSchema :: new ( developer_config) ;
420- let VectorIndexState :: SnapshottedAt ( ref snapshot) = vector_index else {
421- anyhow:: bail!( index_backfilling_error( & query. printable_index_name( ) ?) ) ;
406+ let result: anyhow:: Result < _ > = {
407+ let IndexConfig :: Vector {
408+ ref developer_config,
409+ ..
410+ } = index. metadata . config
411+ else {
412+ anyhow:: bail!( ErrorMetadata :: bad_request(
413+ "IndexNotAVectorIndexError" ,
414+ format!(
415+ "Index {} is not a vector index" ,
416+ query. printable_index_name( ) ?
417+ )
418+ ) ) ;
419+ } ;
420+ let Some ( ( vector_index, memory_index) ) = self . require_ready_index ( & index. id ( ) ) ? else {
421+ anyhow:: bail!( "Vector index {:?} not available" , index. id( ) ) ;
422+ } ;
423+ let qdrant_schema = QdrantSchema :: new ( developer_config) ;
424+ let VectorIndexState :: SnapshottedAt ( ref snapshot) = vector_index else {
425+ anyhow:: bail!( index_backfilling_error( & query. printable_index_name( ) ?) ) ;
426+ } ;
427+ let ( disk_revisions, vector_index_type) = match snapshot. data {
428+ VectorIndexSnapshotData :: Unknown ( _) => {
429+ anyhow:: bail!( index_backfilling_error( & query. printable_index_name( ) ?) )
430+ } ,
431+ VectorIndexSnapshotData :: MultiSegment ( ref segments) => (
432+ self . multi_segment_search (
433+ query,
434+ searcher,
435+ segments,
436+ search_storage,
437+ qdrant_schema,
438+ memory_index,
439+ snapshot. ts ,
440+ )
441+ . await ?,
442+ VectorIndexType :: MultiSegment ,
443+ ) ,
444+ } ;
445+ Ok ( ( disk_revisions, vector_index_type) )
422446 } ;
423- let ( disk_revisions, vector_index_type) = match snapshot. data {
424- VectorIndexSnapshotData :: Unknown ( _) => {
425- anyhow:: bail!( index_backfilling_error( & query. printable_index_name( ) ?) )
447+ match result {
448+ Ok ( ( disk_revisions, vector_index_type) ) => {
449+ metrics:: finish_search ( timer, & disk_revisions, vector_index_type) ;
450+ Ok ( disk_revisions)
426451 } ,
427- VectorIndexSnapshotData :: MultiSegment ( ref segments) => (
428- self . multi_segment_search (
429- query,
430- searcher,
431- segments,
432- search_storage,
433- qdrant_schema,
434- memory_index,
435- snapshot. ts ,
436- )
437- . await ?,
438- VectorIndexType :: MultiSegment ,
439- ) ,
440- } ;
441- metrics:: finish_search ( timer, & disk_revisions, vector_index_type) ;
442- Ok ( disk_revisions)
452+ Err ( e) => {
453+ if e. is_bad_request ( ) {
454+ timer. finish_developer_error ( ) ;
455+ }
456+ Err ( e)
457+ } ,
458+ }
443459 }
444460
445461 async fn multi_segment_search (
0 commit comments