(
&self,
task: &ExecutionTask,
tid: u64,
collection: &str,
query: &str,
top_k: usize,
fuzzy: bool,
prefilter: Option<&nodedb_types::Surr
| 28 | /// Execute a full-text search using BM25 + optional fuzzy matching. |
| 29 | #[allow(clippy::too_many_arguments)] |
| 30 | pub(in crate::data::executor) fn execute_text_search( |
| 31 | &self, |
| 32 | task: &ExecutionTask, |
| 33 | tid: u64, |
| 34 | collection: &str, |
| 35 | query: &str, |
| 36 | top_k: usize, |
| 37 | fuzzy: bool, |
| 38 | prefilter: Option<&nodedb_types::SurrogateBitmap>, |
| 39 | rls_filters: &[u8], |
| 40 | ) -> Response { |
| 41 | let tenant_id = TenantId::new(tid); |
| 42 | debug!(core = self.core_id, tid, %collection, %query, top_k, fuzzy, "text search"); |
| 43 | |
| 44 | // Scan-quiesce gate. |
| 45 | let _scan_guard = match self.acquire_scan_guard(task, tid, collection) { |
| 46 | Ok(g) => g, |
| 47 | Err(resp) => return resp, |
| 48 | }; |
| 49 | |
| 50 | // Fetch extra candidates when RLS is active. |
| 51 | let fetch_k = if rls_filters.is_empty() { |
| 52 | top_k |
| 53 | } else { |
| 54 | top_k.saturating_mul(2).max(20) |
| 55 | }; |
| 56 | |
| 57 | let results = match self |
| 58 | .inverted |
| 59 | .search(tenant_id, collection, query, fetch_k, fuzzy, prefilter) |
| 60 | { |
| 61 | Ok(r) => r, |
| 62 | Err(e) => { |
| 63 | return self.response_error( |
| 64 | task, |
| 65 | ErrorCode::Internal { |
| 66 | detail: e.to_string(), |
| 67 | }, |
| 68 | ); |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | let strict_schema = self.strict_schema_for(tenant_id, collection); |
| 73 | let rows = self.hydrate_text_hits( |
| 74 | tid, |
| 75 | collection, |
| 76 | results.iter().map(|r| (r.doc_id, r.score, r.fuzzy)), |
| 77 | top_k, |
| 78 | rls_filters, |
| 79 | strict_schema.as_ref(), |
| 80 | ); |
| 81 | |
| 82 | if let Some(ref m) = self.metrics { |
| 83 | m.record_fts_search(0); |
| 84 | } |
| 85 | match super::super::response_codec::encode(&rows) { |
| 86 | Ok(payload) => self.response_with_payload(task, payload), |
| 87 | Err(e) => self.response_error( |
no test coverage detected