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 test for default sort property for int/bool fields.
Kishore Nallanb4d05051afd6
diff --git a/test/collection_sorting_test.cpp b/test/collection_sorting_test.cppindex 5687cba8..92671d9d 100644--- a/test/collection_sorting_test.cpp+++ b/test/collection_sorting_test.cpp@@ -1424,4 +1424,46 @@ TEST_F(CollectionSortingTest, RepeatingTokenRanking) {ASSERT_EQ(50291712, results["hits"][3]["text_match"].get<uint32_t>());collectionManager.drop_collection("coll1");-}\ No newline at end of file+}++TEST_F(CollectionSortingTest, IntegerFloatAndBoolShouldDefaultSortTrue) {+ std::string coll_schema = R"(+ {+ "name": "coll1",+ "fields": [+ {"name": "title", "type": "string", "infix": true },+ {"name": "points", "type": "int32" },+ {"name": "timestamp", "type": "int64" },+ {"name": "max", "type": "float" },+ {"name": "is_valid", "type": "bool" }+ ]+ }+ )";++ nlohmann::json schema = nlohmann::json::parse(coll_schema);+ Collection* coll1 = collectionManager.create_collection(schema).get();++ nlohmann::json doc1;+ doc1["id"] = "0";+ doc1["title"] = "Right on";+ doc1["points"] = 100;+ doc1["timestamp"] = 7273272372732;+ doc1["max"] = 97.6;+ doc1["is_valid"] = true;++ ASSERT_TRUE(coll1->add(doc1.dump()).ok());++ auto res_op = coll1->search("*", {"title"}, "", {}, {sort_by("points", "DESC")}, {2}, 10, 1, FREQUENCY, {true}, 10);+ ASSERT_TRUE(res_op.ok());++ res_op = coll1->search("*", {"title"}, "", {}, {sort_by("timestamp", "DESC")}, {2}, 10, 1, FREQUENCY, {true}, 10);+ ASSERT_TRUE(res_op.ok());++ res_op = coll1->search("*", {"title"}, "", {}, {sort_by("max", "DESC")}, {2}, 10, 1, FREQUENCY, {true}, 10);+ ASSERT_TRUE(res_op.ok());++ res_op = coll1->search("*", {"title"}, "", {}, {sort_by("is_valid", "DESC")}, {2}, 10, 1, FREQUENCY, {true}, 10);+ ASSERT_TRUE(res_op.ok());++ collectionManager.drop_collection("coll1");+}