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
Allow sequence id based sorting.
Kishore Nallane80b17085a27
diff --git a/src/collection.cpp b/src/collection.cppindex db5f9046..35a7a697 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -722,7 +722,8 @@ Option<bool> Collection::validate_and_standardize_sort_fields(const std::vector<}}- if (sort_field_std.name != sort_field_const::text_match && sort_field_std.name != sort_field_const::eval) {+ if (sort_field_std.name != sort_field_const::text_match && sort_field_std.name != sort_field_const::eval &&+ sort_field_std.name != sort_field_const::seq_id) {const auto field_it = search_schema.find(sort_field_std.name);if(field_it == search_schema.end() || !field_it.value().sort || !field_it.value().index) {std::string error = "Could not find a field named `" + sort_field_std.name +diff --git a/test/collection_sorting_test.cpp b/test/collection_sorting_test.cppindex 121a0e64..99cb95c7 100644--- a/test/collection_sorting_test.cpp+++ b/test/collection_sorting_test.cpp@@ -1952,6 +1952,32 @@ TEST_F(CollectionSortingTest, DisallowSortingOnNonIndexedIntegerField) {collectionManager.drop_collection("coll1");}+TEST_F(CollectionSortingTest, WildcardSearchSequenceIdSort) {+ nlohmann::json schema = R"({+ "name": "coll1",+ "fields": [+ {"name": "category", "type": "string"}+ ]+ })"_json;++ Collection* coll1 = collectionManager.create_collection(schema).get();++ nlohmann::json doc;+ doc["category"] = "Shoes";++ for(size_t i = 0; i < 30; i++) {+ ASSERT_TRUE(coll1->add(doc.dump()).ok());+ }++ std::vector<sort_by> sort_fields = {+ sort_by("_seq_id", "DESC"),+ };++ auto res = coll1->search("*", {"category"}, "", {}, sort_fields, {2}, 10, 1, FREQUENCY, {true}, 0).get();+ ASSERT_EQ(10, res["hits"].size());+ ASSERT_EQ(30, res["found"].get<size_t>());+}+TEST_F(CollectionSortingTest, OptionalFilteringViaSortingWildcard) {std::string coll_schema = R"({