Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Skip validation of embedding field while reindexing

ozanarmaganb2d07d9a66ba
diff --git a/include/validator.h b/include/validator.h
index 3998f5dc..b4952cf6 100644
--- a/include/validator.h
+++ b/include/validator.h
@@ -31,7 +31,7 @@ public:
const index_operation_t op,
const bool is_update,
const std::string& fallback_field_type,
- const DIRTY_VALUES& dirty_values);
+ const DIRTY_VALUES& dirty_values, const bool validate_embedding_fields = true);
static Option<uint32_t> coerce_element(const field& a_field, nlohmann::json& document,
diff --git a/src/collection.cpp b/src/collection.cpp
index 71ad93f8..1884004b 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -3776,9 +3776,9 @@ Option<bool> Collection::batch_alter_data(const std::vector<field>& alter_fields
index->remove(seq_id, rec.doc, del_fields, true);
}
}
-
+
Index::batch_memory_index(index, iter_batch, default_sorting_field, schema_additions, embedding_fields,
- fallback_field_type, token_separators, symbols_to_index, true);
+ fallback_field_type, token_separators, symbols_to_index, true, false);
iter_batch.clear();
}
diff --git a/src/index.cpp b/src/index.cpp
index df2e3c3f..ce24b8e1 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -441,7 +441,7 @@ void Index::validate_and_preprocess(Index *index, std::vector<index_record>& ite
index_rec.operation,
index_rec.is_update,
fallback_field_type,
- index_rec.dirty_values);
+ index_rec.dirty_values, generate_embeddings);
if(!validation_op.ok()) {
index_rec.index_failure(validation_op.code(), validation_op.error());
diff --git a/src/validator.cpp b/src/validator.cpp
index 04d99ab2..b8516130 100644
--- a/src/validator.cpp
+++ b/src/validator.cpp
@@ -605,7 +605,7 @@ Option<uint32_t> validator_t::validate_index_in_memory(nlohmann::json& document,
const index_operation_t op,
const bool is_update,
const std::string& fallback_field_type,
- const DIRTY_VALUES& dirty_values) {
+ const DIRTY_VALUES& dirty_values, const bool validate_embedding_fields) {
bool missing_default_sort_field = (!default_sorting_field.empty() && document.count(default_sorting_field) == 0);
@@ -652,10 +652,12 @@ Option<uint32_t> validator_t::validate_index_in_memory(nlohmann::json& document,
}
}
- // validate embedding fields
- auto validate_embed_op = validate_embed_fields(document, embedding_fields, search_schema, !is_update);
- if(!validate_embed_op.ok()) {
- return Option<>(validate_embed_op.code(), validate_embed_op.error());
+ if(validate_embedding_fields) {
+ // validate embedding fields
+ auto validate_embed_op = validate_embed_fields(document, embedding_fields, search_schema, !is_update);
+ if(!validate_embed_op.ok()) {
+ return Option<>(validate_embed_op.code(), validate_embed_op.error());
+ }
}
return Option<>(200);