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
Add additional test case for phrase search on long text.
Kishore Nallan59a55d0195fe
diff --git a/src/posting_list.cpp b/src/posting_list.cppindex a8048a69..759d3765 100644--- a/src/posting_list.cpp+++ b/src/posting_list.cpp@@ -1246,9 +1246,7 @@ void posting_list_t::get_phrase_matches(std::vector<iterator_t>& its, bool fieldget_offsets(its, array_token_positions);for(auto& kv: array_token_positions) {- auto dist = Match(id, kv.second, false, false).distance;- bool is_phrase_match = dist == its.size() - 1;- is_phrase_match = Match(id, kv.second, false, false).phrase_match;+ bool is_phrase_match = Match(id, kv.second, false, false).phrase_match;if(is_phrase_match) {phrase_ids[phrase_id_index] = ids[i];phrase_id_index++;diff --git a/test/collection_specific_test.cpp b/test/collection_specific_test.cppindex 501414ad..125bb949 100644--- a/test/collection_specific_test.cpp+++ b/test/collection_specific_test.cpp@@ -2505,3 +2505,33 @@ TEST_F(CollectionSpecificTest, NegationOfTokens) {collectionManager.drop_collection("coll1");}++TEST_F(CollectionSpecificTest, PhraseSearchOnLongText) {+ std::vector<field> fields = {field("title", field_types::STRING, false),};++ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields).get();++ std::vector<std::vector<std::string>> records = {+ {"He goes, Sir, why don't you drive? (Laughter) I don't know where we're going. Neither do I. It will be an adventure, sir. (Laughter) The Middle East has been an adventure the past couple of years. It is going crazy with the Arab Spring and revolution and all this. Are there any Lebanese here tonight, by applause? (Cheering) Lebanese, yeah. The Middle East is going crazy. You know the Middle East is going crazy when Lebanon is the most peaceful place in the region. (Laughter) (Applause) Who would have thought? (Laughter) Oh my gosh."},+ {"Bear in mind this was an ultrasound, so it would have been moving images. It is a reflex of the autonomic nervous system. Now, this is the part of the nervous system that deals with the things that we don't consciously control."},+ {"So there will be a shared autonomy fleet where you buy your car and you can choose to use that car exclusively, you could choose to have it be used only by friends and family."}+ };++ for(size_t i=0; i<records.size(); i++) {+ nlohmann::json doc;++ doc["id"] = std::to_string(i);+ doc["title"] = records[i][0];+ doc["points"] = i;++ ASSERT_TRUE(coll1->add(doc.dump()).ok());+ }++ auto results = coll1->search("\"have it be\"", {"title"},+ "", {}, {}, {2}, 10, 1, FREQUENCY, {true}, 1).get();++ ASSERT_EQ(1, results["hits"].size());+ ASSERT_EQ("2", results["hits"][0]["document"]["id"].get<std::string>());++ collectionManager.drop_collection("coll1");+}