Only reindex if the size increased

This commit is contained in:
Louis Dureuil 2024-09-02 13:52:18 +02:00
parent 66bda2ce8a
commit ed19b7c3c3
No known key found for this signature in database

View File

@ -196,11 +196,22 @@ impl SettingsDiff {
ReindexAction::RegeneratePrompts, ReindexAction::RegeneratePrompts,
); );
} }
if document_template_max_bytes.apply(new_document_template_max_bytes) { if document_template_max_bytes.apply(new_document_template_max_bytes) {
ReindexAction::push_action( let previous_document_template_max_bytes =
&mut reindex_action, document_template_max_bytes.set().unwrap_or(default_max_bytes().get());
ReindexAction::RegeneratePrompts, let new_document_template_max_bytes =
) new_document_template_max_bytes.set().unwrap_or(default_max_bytes().get());
// only reindex if the size increased. Reasoning:
// - size decrease is a performance optimization, so we don't reindex and we keep the more accurate vectors
// - size increase is an accuracy optimization, so we want to reindex
if new_document_template_max_bytes > previous_document_template_max_bytes {
ReindexAction::push_action(
&mut reindex_action,
ReindexAction::RegeneratePrompts,
)
}
} }
distribution.apply(new_distribution); distribution.apply(new_distribution);