Skip to content

Commit e0a7fa2

Browse files
emmaling27Convex, Inc.
authored and
Convex, Inc.
committed
Rename search indexes to text indexes (#27750)
This PR renames search indexes to text indexes when we mean full text search indexes. We have a bunch of generic code for building text and vector indexes where we use the term search index to mean both, so this should help clarify in the codebase what code is specific to text search. I didn't touch anything that's serialized because we should be more careful there about renames. GitOrigin-RevId: 811120b188e43f02a60bafd0076f024a79eeb032
1 parent c2a9d6d commit e0a7fa2

34 files changed

+307
-313
lines changed

crates/common/src/bootstrap_model/index/developer_index_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl From<IndexConfig> for DeveloperIndexConfig {
4141
IndexConfig::Database {
4242
developer_config, ..
4343
} => DeveloperIndexConfig::Database(developer_config),
44-
IndexConfig::Search {
44+
IndexConfig::Text {
4545
developer_config, ..
4646
} => DeveloperIndexConfig::Search(developer_config),
4747
IndexConfig::Vector {

crates/common/src/bootstrap_model/index/index_config.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum IndexConfig {
4141
},
4242

4343
/// Full text search index.
44-
Search {
44+
Text {
4545
developer_config: DeveloperTextIndexConfig,
4646

4747
/// Whether the index is fully backfilled or not on disk.
@@ -60,7 +60,7 @@ impl IndexConfig {
6060
IndexConfig::Database { on_disk_state, .. } => {
6161
matches!(on_disk_state, DatabaseIndexState::Enabled)
6262
},
63-
IndexConfig::Search { on_disk_state, .. } => {
63+
IndexConfig::Text { on_disk_state, .. } => {
6464
matches!(on_disk_state, TextIndexState::SnapshottedAt(_))
6565
},
6666
IndexConfig::Vector { on_disk_state, .. } => {
@@ -74,7 +74,7 @@ impl IndexConfig {
7474
IndexConfig::Database { on_disk_state, .. } => {
7575
matches!(on_disk_state, DatabaseIndexState::Backfilling(_))
7676
},
77-
IndexConfig::Search { on_disk_state, .. } => {
77+
IndexConfig::Text { on_disk_state, .. } => {
7878
matches!(on_disk_state, TextIndexState::Backfilling(_))
7979
},
8080
IndexConfig::Vector { on_disk_state, .. } => {
@@ -95,10 +95,10 @@ impl IndexConfig {
9595
},
9696
) => developer_config == config_to_compare,
9797
(
98-
IndexConfig::Search {
98+
IndexConfig::Text {
9999
developer_config, ..
100100
},
101-
IndexConfig::Search {
101+
IndexConfig::Text {
102102
developer_config: config_to_compare,
103103
..
104104
},
@@ -129,7 +129,7 @@ impl IndexConfig {
129129
/// on other index types will panic.
130130
pub fn estimate_pricing_size_bytes(&self) -> anyhow::Result<u64> {
131131
match self {
132-
IndexConfig::Database { .. } | IndexConfig::Search { .. } => {
132+
IndexConfig::Database { .. } | IndexConfig::Text { .. } => {
133133
// TODO(sam): We should support this for all index types in the future. Right
134134
// now search indexes are free and we estimate the size of
135135
// database indexes. Both of those could instead track usage in their metadata,
@@ -188,7 +188,7 @@ impl TryFrom<IndexConfig> for SerializedIndexConfig {
188188
developer_config: developer_config.try_into()?,
189189
on_disk_state: on_disk_state.try_into()?,
190190
},
191-
IndexConfig::Search {
191+
IndexConfig::Text {
192192
developer_config,
193193
on_disk_state,
194194
} => SerializedIndexConfig::Search {
@@ -221,7 +221,7 @@ impl TryFrom<SerializedIndexConfig> for IndexConfig {
221221
SerializedIndexConfig::Search {
222222
developer_config,
223223
on_disk_state,
224-
} => IndexConfig::Search {
224+
} => IndexConfig::Text {
225225
developer_config: developer_config.try_into()?,
226226
on_disk_state: on_disk_state.try_into()?,
227227
},

crates/common/src/bootstrap_model/index/index_metadata.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ impl<T: IndexTableIdentifier> IndexMetadata<T> {
7878
}
7979
}
8080

81-
pub fn new_backfilling_search_index(
81+
pub fn new_backfilling_text_index(
8282
name: GenericIndexName<T>,
8383
search_field: FieldPath,
8484
filter_fields: BTreeSet<FieldPath>,
8585
) -> Self {
86-
Self::new_search_index(
86+
Self::new_text_index(
8787
name,
8888
DeveloperTextIndexConfig {
8989
search_field,
@@ -116,14 +116,14 @@ impl<T: IndexTableIdentifier> IndexMetadata<T> {
116116
}
117117
}
118118

119-
pub fn new_search_index(
119+
pub fn new_text_index(
120120
name: GenericIndexName<T>,
121121
developer_config: DeveloperTextIndexConfig,
122122
on_disk_state: TextIndexState,
123123
) -> Self {
124124
Self {
125125
name,
126-
config: IndexConfig::Search {
126+
config: IndexConfig::Text {
127127
developer_config,
128128
on_disk_state,
129129
},
@@ -144,8 +144,8 @@ impl<T: IndexTableIdentifier> IndexMetadata<T> {
144144
matches!(self.config, IndexConfig::Database { .. })
145145
}
146146

147-
pub fn is_search_index(&self) -> bool {
148-
matches!(self.config, IndexConfig::Search { .. })
147+
pub fn is_text_index(&self) -> bool {
148+
matches!(self.config, IndexConfig::Text { .. })
149149
}
150150

151151
pub fn is_vector_index(&self) -> bool {

crates/common/src/bootstrap_model/index/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ pub static TABLE_ID_FIELD_PATH: LazyLock<FieldPath> =
3535
LazyLock::new(|| FieldPath::new(vec![TABLE_ID_FIELD_NAME.clone()]).unwrap());
3636

3737
pub const MAX_INDEX_FIELDS_SIZE: usize = 16;
38-
pub const MAX_SEARCH_INDEX_FILTER_FIELDS_SIZE: usize = 16;
38+
pub const MAX_TEXT_INDEX_FILTER_FIELDS_SIZE: usize = 16;
3939
pub const MAX_VECTOR_INDEX_FILTER_FIELDS_SIZE: usize = 16;

crates/common/src/bootstrap_model/index/text_index/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ mod tests {
3636
#![proptest_config(ProptestConfig { cases: 64 * env_config("CONVEX_PROPTEST_MULTIPLIER", 1), failure_persistence: None, .. ProptestConfig::default() })]
3737

3838
#[test]
39-
fn test_developer_search_index_config_roundtrips(v in any::<DeveloperTextIndexConfig>()) {
39+
fn test_developer_text_index_config_roundtrips(v in any::<DeveloperTextIndexConfig>()) {
4040
assert_roundtrips::<
4141
DeveloperTextIndexConfig,
4242
pb::searchlight::SearchIndexConfig

crates/common/src/knobs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ pub static BACKEND_STARTUP_DELAY: LazyLock<Duration> =
364364
LazyLock::new(|| Duration::from_secs(env_config("BACKEND_STARTUP_DELAY_SECS", 0)));
365365

366366
/// When to start rejecting new additions to the search memory index.
367-
pub static SEARCH_INDEX_SIZE_HARD_LIMIT: LazyLock<usize> =
367+
pub static TEXT_INDEX_SIZE_HARD_LIMIT: LazyLock<usize> =
368368
LazyLock::new(|| env_config("SEARCH_INDEX_SIZE_HARD_LIMIT", 100 * (1 << 20))); // 100 MiB
369369

370370
/// When to start rejecting new additions to the vector memory index.

crates/common/src/schemas/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use crate::{
4343
database_index::IndexedFields,
4444
index_validation_error,
4545
vector_index::VectorDimensions,
46-
MAX_SEARCH_INDEX_FILTER_FIELDS_SIZE,
46+
MAX_TEXT_INDEX_FILTER_FIELDS_SIZE,
4747
MAX_VECTOR_INDEX_FILTER_FIELDS_SIZE,
4848
},
4949
document::ResolvedDocument,
@@ -672,9 +672,9 @@ impl SearchIndexSchema {
672672
search_field: FieldPath,
673673
filter_fields: BTreeSet<FieldPath>,
674674
) -> anyhow::Result<Self> {
675-
if filter_fields.len() > MAX_SEARCH_INDEX_FILTER_FIELDS_SIZE {
675+
if filter_fields.len() > MAX_TEXT_INDEX_FILTER_FIELDS_SIZE {
676676
anyhow::bail!(index_validation_error::too_many_filter_fields(
677-
MAX_SEARCH_INDEX_FILTER_FIELDS_SIZE
677+
MAX_TEXT_INDEX_FILTER_FIELDS_SIZE
678678
));
679679
}
680680
Ok(Self {

crates/common/src/testing/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use serde_json::{
1010
use crate::{
1111
bootstrap_model::index::{
1212
MAX_INDEX_FIELDS_SIZE,
13-
MAX_SEARCH_INDEX_FILTER_FIELDS_SIZE,
13+
MAX_TEXT_INDEX_FILTER_FIELDS_SIZE,
1414
MAX_VECTOR_INDEX_FILTER_FIELDS_SIZE,
1515
},
1616
schemas::{
@@ -790,7 +790,7 @@ fn test_too_many_fields() {
790790

791791
#[test]
792792
fn test_too_many_search_filter_fields() {
793-
let fields: Vec<_> = (0..MAX_SEARCH_INDEX_FILTER_FIELDS_SIZE + 1)
793+
let fields: Vec<_> = (0..MAX_TEXT_INDEX_FILTER_FIELDS_SIZE + 1)
794794
.map(|i| format!("field_{}", i))
795795
.collect();
796796
let value = json!({

crates/database/src/bootstrap_model/index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<'a, RT: Runtime> IndexModel<'a, RT> {
224224
*on_disk_state = DatabaseIndexState::Enabled;
225225
},
226226
},
227-
IndexConfig::Search {
227+
IndexConfig::Text {
228228
ref mut on_disk_state,
229229
..
230230
} => match on_disk_state {
@@ -385,7 +385,7 @@ impl<'a, RT: Runtime> IndexModel<'a, RT> {
385385
// Collect the search indexes.
386386
for (index_descriptor, index_schema) in &table_schema.search_indexes {
387387
let index_name = IndexName::new(table_name.clone(), index_descriptor.clone())?;
388-
indexes_in_schema.push(IndexMetadata::new_backfilling_search_index(
388+
indexes_in_schema.push(IndexMetadata::new_backfilling_text_index(
389389
index_name.clone(),
390390
index_schema.search_field.clone(),
391391
index_schema.filter_fields.clone(),
@@ -912,14 +912,14 @@ impl<'a, RT: Runtime> IndexModel<'a, RT> {
912912
developer_config: DeveloperDatabaseIndexConfig { fields },
913913
..
914914
} => IndexMetadata::new_backfilling(*self.tx.begin_timestamp(), index_name, fields),
915-
IndexConfig::Search {
915+
IndexConfig::Text {
916916
developer_config:
917917
DeveloperTextIndexConfig {
918918
search_field,
919919
filter_fields,
920920
},
921921
..
922-
} => IndexMetadata::new_backfilling_search_index(
922+
} => IndexMetadata::new_backfilling_text_index(
923923
index_name,
924924
search_field,
925925
filter_fields,

crates/database/src/committer.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ use crate::{
107107
finish_bootstrap_update,
108108
},
109109
reads::ReadSet,
110-
search_and_vector_bootstrap::{
110+
search_index_bootstrap::{
111111
stream_revision_pairs_for_indexes,
112-
BootstrappedSearchAndVectorIndexes,
112+
BootstrappedSearchIndexes,
113113
},
114114
snapshot_manager::SnapshotManager,
115115
transaction::FinalTransaction,
@@ -285,7 +285,7 @@ impl<RT: Runtime> Committer<RT> {
285285
Some(CommitterMessage::BumpMaxRepeatableTs { result }) => {
286286
self.bump_max_repeatable_ts(result);
287287
},
288-
Some(CommitterMessage::FinishSearchAndVectorBootstrap {
288+
Some(CommitterMessage::FinishTextAndVectorBootstrap {
289289
bootstrapped_indexes,
290290
bootstrap_ts,
291291
result,
@@ -309,18 +309,18 @@ impl<RT: Runtime> Committer<RT> {
309309
}
310310

311311
async fn update_indexes_since_bootstrap(
312-
BootstrappedSearchAndVectorIndexes {
313-
search_index_manager,
312+
BootstrappedSearchIndexes {
313+
text_index_manager,
314314
vector_index_manager,
315315
tables_with_indexes,
316-
}: &mut BootstrappedSearchAndVectorIndexes<RT>,
316+
}: &mut BootstrappedSearchIndexes<RT>,
317317
bootstrap_ts: Timestamp,
318318
persistence: RepeatablePersistence,
319319
registry: &IndexRegistry,
320320
) -> anyhow::Result<()> {
321321
let _timer = bootstrap_update_timer();
322322
anyhow::ensure!(
323-
!search_index_manager.is_bootstrapping(),
323+
!text_index_manager.is_bootstrapping(),
324324
"Trying to update search index while it's still bootstrapping"
325325
);
326326
anyhow::ensure!(
@@ -338,7 +338,7 @@ impl<RT: Runtime> Committer<RT> {
338338
while let Some(revision_pair) = revision_stream.try_next().await? {
339339
num_revisions += 1;
340340
total_size += revision_pair.document().map(|d| d.size()).unwrap_or(0);
341-
search_index_manager.update(
341+
text_index_manager.update(
342342
registry,
343343
revision_pair.prev_document(),
344344
revision_pair.document(),
@@ -357,7 +357,7 @@ impl<RT: Runtime> Committer<RT> {
357357

358358
async fn finish_search_and_vector_bootstrap(
359359
&mut self,
360-
mut bootstrapped_indexes: BootstrappedSearchAndVectorIndexes<RT>,
360+
mut bootstrapped_indexes: BootstrappedSearchIndexes<RT>,
361361
bootstrap_ts: RepeatableTimestamp,
362362
result: oneshot::Sender<anyhow::Result<()>>,
363363
) {
@@ -393,8 +393,8 @@ impl<RT: Runtime> Committer<RT> {
393393
if latest_ts != snapshot_manager.latest_ts() {
394394
panic!("Snapshots were changed concurrently during commit?");
395395
}
396-
snapshot_manager.overwrite_last_snapshot_search_and_vector_indexes(
397-
bootstrapped_indexes.search_index_manager,
396+
snapshot_manager.overwrite_last_snapshot_text_and_vector_indexes(
397+
bootstrapped_indexes.text_index_manager,
398398
bootstrapped_indexes.vector_index_manager,
399399
);
400400
tracing::info!("Committed backfilled vector indexes");
@@ -849,11 +849,11 @@ impl<RT: Runtime> Clone for CommitterClient<RT> {
849849
impl<RT: Runtime> CommitterClient<RT> {
850850
pub async fn finish_search_and_vector_bootstrap(
851851
&self,
852-
bootstrapped_indexes: BootstrappedSearchAndVectorIndexes<RT>,
852+
bootstrapped_indexes: BootstrappedSearchIndexes<RT>,
853853
bootstrap_ts: RepeatableTimestamp,
854854
) -> anyhow::Result<()> {
855855
let (tx, rx) = oneshot::channel();
856-
let message = CommitterMessage::FinishSearchAndVectorBootstrap {
856+
let message = CommitterMessage::FinishTextAndVectorBootstrap {
857857
bootstrapped_indexes,
858858
bootstrap_ts,
859859
result: tx,
@@ -1012,8 +1012,8 @@ enum CommitterMessage<RT: Runtime> {
10121012
tables: BTreeSet<TableName>,
10131013
result: oneshot::Sender<anyhow::Result<()>>,
10141014
},
1015-
FinishSearchAndVectorBootstrap {
1016-
bootstrapped_indexes: BootstrappedSearchAndVectorIndexes<RT>,
1015+
FinishTextAndVectorBootstrap {
1016+
bootstrapped_indexes: BootstrappedSearchIndexes<RT>,
10171017
bootstrap_ts: RepeatableTimestamp,
10181018
result: oneshot::Sender<anyhow::Result<()>>,
10191019
},

0 commit comments

Comments
 (0)