Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default dynamic mapping config #5653

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions quickwit/quickwit-config/src/index_config/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,45 @@ mod test {
}
}

#[test]
fn test_default_dynamic_mapping_matches_docs() {
let minimal_config_yaml = r#"
version: 0.8
index_id: hdfs-logs
doc_mapping:
doc_mapping_uid: 00000000000000000000000000
"#;
let docs_config_yaml = r#"
version: 0.8
index_id: hdfs-logs
doc_mapping:
doc_mapping_uid: 00000000000000000000000000
mode: dynamic
dynamic_mapping:
indexed: true
stored: true
tokenizer: default
record: basic
expand_dots: true
fast: true
"#;
{
let minimal_index_config: IndexConfig = load_index_config_from_user_config(
ConfigFormat::Yaml,
minimal_config_yaml.as_bytes(),
&Uri::for_test("s3://mybucket"),
)
.unwrap();
let docs_index_config: IndexConfig = load_index_config_from_user_config(
ConfigFormat::Yaml,
docs_config_yaml.as_bytes(),
&Uri::for_test("s3://mybucket"),
)
.unwrap();
assert_eq!(minimal_index_config, docs_index_config);
}
}

#[test]
fn test_update_index_root_uri() {
let original_config_yaml = r#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ impl TextIndexingOptions {
fieldnorms: false,
}
}

fn default_dynamic() -> Self {
TextIndexingOptions {
tokenizer: QuickwitTextTokenizer::default(),
record: IndexRecordOption::Basic,
fieldnorms: false,
}
}
}

impl Default for TextIndexingOptions {
Expand Down Expand Up @@ -611,8 +619,11 @@ impl QuickwitJsonOptions {
/// Build a default QuickwitJsonOptions for dynamic fields.
pub fn default_dynamic() -> Self {
QuickwitJsonOptions {
description: None,
indexing_options: Some(TextIndexingOptions::default_dynamic()),
stored: true,
expand_dots: true,
fast: FastFieldOptions::default_enabled(),
..Default::default()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-doc-mapper/src/doc_mapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ mod tests {
tantivy_schema.get_field_entry(dynamic_field).field_type()
{
let text_opt = json_options.get_text_indexing_options().unwrap();
assert_eq!(text_opt.tokenizer(), "raw");
assert_eq!(text_opt.tokenizer(), "default");
} else {
panic!("dynamic field should be of JSON type");
}
Expand Down
Loading