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
Merge branch '0.22.0-rc' into postings-refactor-integration
Kishore Nallan261536d0f47c
diff --cc src/collection.cppindex d0a4cc21,640e744b..3f157723--- a/src/collection.cpp+++ b/src/collection.cpp@@@ -1497,21 -1525,40 +1526,30 @@@ void Collection::highlight_result(consstd::vector<art_leaf*> query_suggestion;std::set<std::string> query_suggestion_tokens;- for (const art_leaf* token_leaf : searched_queries[field_order_kv->query_index]) {- // Must search for the token string fresh on that field for the given document since `token_leaf`- // is from the best matched field and need not be present in other fields of a document.- Index* index = indices[field_order_kv->key % num_memory_shards];- art_leaf *actual_leaf = index->get_token_leaf(search_field.name, &token_leaf->key[0], token_leaf->key_len);+ size_t qindex = 0;++ do {+ auto searched_query =+ (field_order_kv->query_indices == nullptr) ? searched_queries[field_order_kv->query_index] :+ searched_queries[field_order_kv->query_indices[qindex + 1]];- //LOG(INFO) << "field: " << search_field.name << ", key: " << token_leaf->key;+ for (art_leaf* token_leaf : searched_query) {+ // Must search for the token string fresh on that field for the given document since `token_leaf`+ // is from the best matched field and need not be present in other fields of a document.+ Index* index = indices[field_order_kv->key % num_memory_shards];+ art_leaf* actual_leaf = index->get_token_leaf(search_field.name, &token_leaf->key[0], token_leaf->key_len);- if(actual_leaf != nullptr) {- query_suggestion.push_back(actual_leaf);- std::string token(reinterpret_cast<char*>(actual_leaf->key), actual_leaf->key_len-1);- query_suggestion_tokens.insert(token);- if(actual_leaf == nullptr) {- continue;- }-- uint32_t doc_index = actual_leaf->values->ids.indexOf(field_order_kv->key);- if(doc_index != actual_leaf->values->ids.getLength()) {++ if(actual_leaf != nullptr) {+ query_suggestion.push_back(actual_leaf);+ std::string token(reinterpret_cast<char*>(actual_leaf->key), actual_leaf->key_len - 1);+ //LOG(INFO) << "field: " << search_field.name << ", key: " << token;+ query_suggestion_tokens.insert(token);- auto doc_indices = new uint32_t[1];- doc_indices[0] = doc_index;- leaf_to_indices.push_back(doc_indices);+ }}- }++ qindex++;+ } while(field_order_kv->query_indices != nullptr && qindex < field_order_kv->query_indices[0]);-if(query_suggestion.size() != q_tokens.size()) {// can happen for compound query matched across 2 fields when some tokens are droppedfor(const std::string& q_token: q_tokens) {@@@ -1524,7 -1573,14 +1562,8 @@@reinterpret_cast<const unsigned char *>(q_token.c_str()),q_token.size() + 1);if(actual_leaf != nullptr) {- std::vector<uint16_t> positions;- uint32_t doc_index = actual_leaf->values->ids.indexOf(field_order_kv->key);- if(doc_index != actual_leaf->values->ids.getLength()) {- auto doc_indices = new uint32_t[1];- doc_indices[0] = doc_index;- leaf_to_indices.push_back(doc_indices);- query_suggestion.push_back(actual_leaf);- }+ query_suggestion.push_back(actual_leaf);++ query_suggestion_tokens.insert(q_token);}}}