diff --git a/test/collection_filtering_test.cpp b/test/collection_filtering_test.cpp index de1e0a1d..f03d4677 100644 --- a/test/collection_filtering_test.cpp +++ b/test/collection_filtering_test.cpp @@ -1400,4 +1400,39 @@ TEST_F(CollectionFilteringTest, FilterStringsWithComma) { ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get().c_str()); collectionManager.drop_collection("coll1"); -} \ No newline at end of file +} + +TEST_F(CollectionFilteringTest, NumericalRangeFilter) { + std::vector fields = {field("company", field_types::STRING, true), + field("num_employees", field_types::INT32, false),}; + + Collection* coll1 = collectionManager.create_collection("coll1", 1, fields, "num_employees").get(); + + std::vector> records = { + {"123", "Company 1", "50"}, + {"125", "Company 2", "150"}, + {"127", "Company 3", "250"}, + {"129", "Stark Industries 4", "500"}, + }; + + for(size_t i=0; iadd(doc.dump()).ok()); + } + + std::vector sort_fields = { sort_by("num_employees", "ASC") }; + + auto results = coll1->search("*", {}, "num_employees:>=100 && num_employees:<=300", {}, sort_fields, {0}, 10, 1, + FREQUENCY, {true}, 10).get(); + + ASSERT_EQ(2, results["found"].get()); + ASSERT_STREQ("125", results["hits"][0]["document"]["id"].get().c_str()); + ASSERT_STREQ("127", results["hits"][1]["document"]["id"].get().c_str()); + + collectionManager.drop_collection("coll1"); +}