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

Merge branch 'v0.25-join' into v0.25-join

Ozan Armağan24e309e50d21
diff --cc src/collection.cpp
index 3f00ef05,1c3e51b1..056885b9
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@@ -4794,14 -4771,20 +4794,31 @@@ void Collection::process_remove_field_f
}
+void Collection::hide_credential(nlohmann::json& json, const std::string& credential_name) {
+ if(json.count(credential_name) != 0) {
+ // hide api key with * except first 3 chars
+ std::string credential_name_str = json[credential_name];
+ if(credential_name_str.size() > 3) {
+ json[credential_name] = credential_name_str.replace(3, credential_name_str.size() - 3, credential_name_str.size() - 3, '*');
+ } else {
+ json[credential_name] = credential_name_str.replace(0, credential_name_str.size(), credential_name_str.size(), '*');
+ }
+ }
- }
++}
+ Option<bool> Collection::truncate_after_top_k(const string &field_name, size_t k) {
+ std::vector<uint32_t> seq_ids;
+ auto op = index->seq_ids_outside_top_k(field_name, k, seq_ids);
+
+ if(!op.ok()) {
+ return op;
+ }
+
+ for(auto seq_id: seq_ids) {
+ auto remove_op = remove_if_found(seq_id);
+ if(!remove_op.ok()) {
+ LOG(ERROR) << "Error while truncating top k: " << remove_op.error();
+ }
+ }
+
+ return Option<bool>(true);
+ }