Add detailed spans

This commit is contained in:
Louis Dureuil 2024-07-31 13:05:47 +02:00
parent 7c3fc8c655
commit 0e68718027
No known key found for this signature in database

View File

@ -269,16 +269,36 @@ fn extract_facet_string_docids_settings<R: io::Read + io::Seek>(
}
/// Normalizes the facet string and truncates it to the max length.
#[tracing::instrument(level = "trace", skip_all, target = "indexing::extract")]
fn normalize_facet_string(facet_string: &str, locales: Option<&[Language]>) -> String {
let options = NormalizerOption { lossy: true, ..Default::default() };
let mut detection = StrDetection::new(facet_string, locales);
let script = {
let span = tracing::trace_span!(target: "indexing::extract::extract_facet_string_docids", "detect_script");
let _entered = span.enter();
detection.script()
};
let language = {
let span = tracing::trace_span!(target: "indexing::extract::extract_facet_string_docids", "detect_language");
let _entered = span.enter();
detection.language()
};
let token = Token {
lemma: std::borrow::Cow::Borrowed(facet_string),
script: detection.script(),
language: detection.language(),
script,
language,
..Default::default()
};
let span =
tracing::trace_span!(target: "indexing::extract::extract_facet_string_docids", "normalize");
let _entered = span.enter();
// truncate the facet string to the max length
token
.normalize(&options)