1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// SPDX-License-Identifier: BUSL-1.1
//! Text (FTS) operation dispatch.
use crate::bridge::envelope::Response;
use nodedb_physical::physical_plan::TextOp;
use crate::data::executor::core_loop::CoreLoop;
use crate::data::executor::task::ExecutionTask;
impl CoreLoop {
pub(super) fn dispatch_text(&mut self, task: &ExecutionTask, op: &TextOp) -> Response {
let tid = task.request.tenant_id.as_u64();
match op {
TextOp::Search {
collection,
query,
top_k,
fuzzy,
prefilter,
rls_filters,
} => self.execute_text_search(
task,
tid,
collection,
query,
*top_k,
*fuzzy,
prefilter.as_ref(),
rls_filters,
),
TextOp::BM25ScoreScan {
collection,
query,
score_alias,
fuzzy,
} => self.execute_bm25_score_scan(task, tid, collection, query, score_alias, *fuzzy),
TextOp::PhraseSearch {
collection,
terms,
top_k,
prefilter,
} => {
self.execute_phrase_search(task, tid, collection, terms, *top_k, prefilter.as_ref())
}
TextOp::HybridSearch {
collection,
query_vector,
query_text,
top_k,
ef_search,
fuzzy,
vector_weight,
filter_bitmap,
rls_filters,
score_alias,
} => self.execute_hybrid_search(
task,
tid,
collection,
query_vector,
query_text,
*top_k,
*ef_search,
*fuzzy,
*vector_weight,
filter_bitmap.as_ref(),
rls_filters,
score_alias.as_deref(),
),
TextOp::FtsIndexDoc {
collection,
surrogate,
text,
} => {
use nodedb_types::TenantId;
let tenant_id = TenantId::new(tid);
match self
.inverted
.index_document(tenant_id, collection, *surrogate, text)
{
Ok(()) => self.response_ok(task),
Err(e) => {
tracing::warn!(
core = self.core_id,
%collection,
surrogate = surrogate.as_u32(),
error = %e,
"FtsIndexDoc: inverted index write failed"
);
self.response_error(task, e)
}
}
}
TextOp::FtsDeleteDoc {
collection,
surrogate,
} => {
use nodedb_types::TenantId;
let tenant_id = TenantId::new(tid);
match self
.inverted
.remove_document(tenant_id, collection, *surrogate)
{
Ok(()) => self.response_ok(task),
Err(e) => {
tracing::warn!(
core = self.core_id,
%collection,
surrogate = surrogate.as_u32(),
error = %e,
"FtsDeleteDoc: inverted index removal failed"
);
self.response_error(task, e)
}
}
}
TextOp::HybridSearchTriple {
collection,
query_vector,
query_text,
graph_seed_id,
graph_depth,
graph_edge_label,
top_k,
ef_search,
fuzzy,
rrf_k,
filter_bitmap,
rls_filters,
score_alias,
} => self.execute_hybrid_search_triple(
task,
tid,
collection,
query_vector,
query_text,
graph_seed_id,
*graph_depth,
graph_edge_label.as_deref(),
*top_k,
*ef_search,
*fuzzy,
*rrf_k,
filter_bitmap.as_ref(),
rls_filters,
score_alias.as_deref(),
),
}
}
}