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
Always use facet hash index.
Kishore Nallan1135680e151d
diff --git a/include/array_base.h b/include/array_base.hindex f04bbc9d..dd3d1eae 100644--- a/include/array_base.h+++ b/include/array_base.h@@ -13,7 +13,7 @@class array_base {protected:- uint8_t* in;+ uint8_t* in = nullptr;uint32_t size_bytes = 0; // allocated sizeuint32_t length_bytes = 0; // actual sizeuint32_t length = 0;diff --git a/include/facet_index.h b/include/facet_index.hindex 575a6964..50981801 100644--- a/include/facet_index.h+++ b/include/facet_index.h@@ -74,17 +74,19 @@ private:struct facet_doc_ids_list_t {tsl::htrie_map<char, facet_id_seq_ids_t> fvalue_seq_ids;std::list<facet_count_t> counts;- posting_list_t* seq_id_hashes;+ posting_list_t* seq_id_hashes = nullptr;bool has_value_index = true;- bool has_hash_index = false;+ bool has_hash_index = true;facet_doc_ids_list_t() {fvalue_seq_ids.clear();counts.clear();- seq_id_hashes = nullptr;+ seq_id_hashes = new posting_list_t(256);}+ facet_doc_ids_list_t(const facet_doc_ids_list_t& other) = delete;+~facet_doc_ids_list_t() {for(auto it = fvalue_seq_ids.begin(); it != fvalue_seq_ids.end(); ++it) {if(it.value().seq_ids) {diff --git a/src/facet_index.cpp b/src/facet_index.cppindex 0c5d495e..b6eb36b2 100644--- a/src/facet_index.cpp+++ b/src/facet_index.cpp@@ -6,8 +6,8 @@void facet_index_t::initialize(const std::string& field) {const auto facet_field_map_it = facet_field_map.find(field);if(facet_field_map_it == facet_field_map.end()) {- facet_doc_ids_list_t facet_doc_ids_list;- facet_field_map.emplace(field, std::move(facet_doc_ids_list));+ // NOTE: try_emplace is needed to construct the value object in-place without calling the destructor+ facet_field_map.try_emplace(field);}}@@ -160,7 +160,11 @@ size_t facet_index_t::intersect(const std::string& field, const uint32_t* result//LOG(INFO) << "fvalue_seq_ids size " << facet_index_map.size() << " , counts size " << counter_list.size();- size_t max_facets = std::min((size_t)2 * max_facet_count, counter_list.size());+ // We look 2 * max_facet_count when keyword search / filtering is involved to ensure that we+ // try and pick the actual top facets by count.+ size_t max_facets = is_wildcard_no_filter_query ? std::min((size_t)max_facet_count, counter_list.size()) :+ std::min((size_t)2 * max_facet_count, counter_list.size());+std::vector<uint32_t> id_list;for(const auto& facet_count : counter_list) {//LOG(INFO) << "checking ids in facet_value " << facet_count.facet_value << " having total count "diff --git a/src/index.cpp b/src/index.cppindex f2a98987..0dd18a47 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -35,7 +35,7 @@search_cutoff = true; \break;\}-#define FACET_INDEX_THRESHOLD 250+#define FACET_INDEX_THRESHOLD 1000000000spp::sparse_hash_map<uint32_t, int64_t> Index::text_match_sentinel_value;spp::sparse_hash_map<uint32_t, int64_t> Index::seq_id_sentinel_value;@@ -660,10 +660,10 @@ void Index::index_field_in_memory(const field& afield, std::vector<index_record>facet_count = FACET_INDEX_THRESHOLD + 1;#endif- if(afield.facet) {+ /*if(afield.facet) {size_t total_num_docs = seq_ids->num_ids();facet_index_v4->handle_index_change(afield.name, total_num_docs, FACET_INDEX_THRESHOLD, facet_count);- }+ }*/for(const auto& record: iter_batch) {if(!record.indexed.ok()) {