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
Don't return error if limit_hits is hit.
Kishore Nallane252f89a4fca
diff --git a/src/collection.cpp b/src/collection.cppindex 2e07d0d2..cad52e5e 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -2065,13 +2065,7 @@ Option<nlohmann::json> Collection::search(std::string raw_query,offset = (per_page * (actual_page - 1));}- size_t fetch_size = offset + per_page;-- if(fetch_size > limit_hits) {- std::string message = "Only upto " + std::to_string(limit_hits) + " hits can be fetched. " +- "Ensure that `page` and `per_page` parameters are within this range.";- return Option<nlohmann::json>(422, message);- }+ size_t fetch_size = std::min<size_t>(offset + per_page, limit_hits);size_t max_hits = DEFAULT_TOPSTER_SIZE;diff --git a/test/collection_test.cpp b/test/collection_test.cppindex 2d6610a6..e5a3b841 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -3072,16 +3072,24 @@ TEST_F(CollectionTest, WildcardQueryReturnsResultsBasedOnPerPageParam) {ASSERT_EQ(25, results["found"].get<int>());// enforce limit_hits- res_op = collection->search("*", query_fields, "", facets, sort_fields, {0}, 10, 3,+ auto limit_hits = 20;+ results = collection->search("*", query_fields, "", facets, sort_fields, {0}, 10, 3,FREQUENCY, {false}, 1000,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,- "<mark>", "</mark>", {1}, 20);+ "<mark>", "</mark>", {1}, limit_hits).get();- ASSERT_FALSE(res_op.ok());- ASSERT_STREQ(- "Only upto 20 hits can be fetched. Ensure that `page` and `per_page` parameters are within this range.",- res_op.error().c_str());+ ASSERT_EQ(0, results["hits"].size());+ ASSERT_EQ(25, results["found"].get<int>());++ results = collection->search("*", query_fields, "", facets, sort_fields, {0}, 15, 2,+ FREQUENCY, {false}, 1000,+ spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,+ "<mark>", "</mark>", {1}, limit_hits).get();++ ASSERT_EQ(5, results["hits"].size());+ ASSERT_EQ(25, results["found"].get<int>());}TEST_F(CollectionTest, RemoveIfFound) {