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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Made a few comments better.
Kishore Nallan70d95475d9ad
diff --git a/include/collection.h b/include/collection.hindex c61b8497..7b53462e 100644--- a/include/collection.h+++ b/include/collection.h@@ -56,7 +56,7 @@ public:Collection() = delete;Collection(const std::string name, const uint32_t collection_id, const uint32_t next_seq_id, Store *store,- const std::vector<field> & fields, const std::string & token_ranking_field);+ const std::vector<field> & fields, const std::string & token_ranking_field, const size_t num_indices=4);~Collection();diff --git a/include/sorted_array.h b/include/sorted_array.hindex 8f90b32e..5df7037f 100644--- a/include/sorted_array.h+++ b/include/sorted_array.h@@ -28,7 +28,6 @@ private:public:- // FIXME: this should be a constructor instead of a settervoid load(const uint32_t *sorted_array, const uint32_t array_length);uint32_t at(uint32_t index);diff --git a/include/string_utils.h b/include/string_utils.hindex 411f3065..d69c9dc8 100644--- a/include/string_utils.h+++ b/include/string_utils.h@@ -127,7 +127,6 @@ struct StringUtils {return !std::isalnum(c) && (int)(c) >= 0;}), str.end());- //std::transform(str.begin(), str.end(), str.begin(), ::tolower);str = miniutf::lowercase(str);}diff --git a/src/collection.cpp b/src/collection.cppindex 91bd346a..2391c654 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -14,7 +14,7 @@Collection::Collection(const std::string name, const uint32_t collection_id, const uint32_t next_seq_id, Store *store,const std::vector<field> &fields, const std::string & token_ranking_field):name(name), collection_id(collection_id), next_seq_id(next_seq_id), store(store),- fields(fields), token_ranking_field(token_ranking_field) {+ fields(fields), token_ranking_field(token_ranking_field), num_indices(num_indices) {for(const field& field: fields) {search_schema.emplace(field.name, field);@@ -29,7 +29,6 @@ Collection::Collection(const std::string name, const uint32_t collection_id, con}}- num_indices = 4;for(size_t i = 0; i < num_indices; i++) {Index* index = new Index(name+std::to_string(i), search_schema, facet_schema, sort_schema);indices.push_back(index);@@ -510,6 +509,7 @@ Option<nlohmann::json> Collection::search(std::string query, const std::vector<sconst int end_result_index = std::min(int(page * per_page), kvsize) - 1;+ // construct results arrayfor(int field_order_kv_index = start_result_index; field_order_kv_index <= end_result_index; field_order_kv_index++) {const auto & field_order_kv = field_order_kvs[field_order_kv_index];const std::string& seq_id_key = get_seq_id_key((uint32_t) field_order_kv.second.key);diff --git a/src/index.cpp b/src/index.cppindex c00d857e..1ceeb5ba 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -937,7 +937,8 @@ inline std::vector<art_leaf *> Index::next_suggestion(const std::vector<token_caquery_suggestion[i] = token_candidates_vec[i].candidates[q.rem];}- // sort ascending based on matched documents for each token for faster intersection+ // Sort ascending based on matched documents for each token for faster intersection.+ // However, this causes the token order to deviate from original query's order.sort(query_suggestion.begin(), query_suggestion.end(), [](const art_leaf* left, const art_leaf* right) {return left->values->ids.getLength() < right->values->ids.getLength();});